Hi,
I'm pulling information from an Access Database to display on the internet. I have several date fields in the database that may or may not contain dates. When there are no dates I would like the field (in the table) to just be blank. However, I keep getting errors like the following when I encounter blank fields:
Warning: Unsupported variant type: 1 (0x1) in D:\Inetpub\billings\pwe\employee\php_test\display_pci.php on line 156
Several text and integer fields work great. Just a problem with the [blank] date fields.
I have tried to test to see if the field is null (is_null()) and that doesn't seem to work. I have tried to test the length of the field (strlen()) to see if it's shorter than a valid length and can't seem to get that working either. I would really appreciate any help anyone can offer as to how to get the blank entries to display w/o the error messages.
Here is how I connect to the database:
//============================
//Open Database Connection
//============================
$db = 'D:\Inetpub\billings\pwe\data\pwe1.mdb';
$conn = new COM('ADODB.Connection');
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db"
;
$SQL = "SELECT * FROM [2004_PCI] WHERE [2004_PCI].Name = '".$StrStreetName."'";
//=====================
// FOR DE-BUGGING
//=====================
//echo $SQL."<BR>";
$rs = $conn->Execute($SQL);
if ($rs->EOF)
{
$rs.Close();
$conn.Close();
//Response.Redirect("SelectStreet.asp?Error=yes"
//Response.End
}
else
{
$rs->MoveFirst();
}
And then when I want to display the info:
<? while (!$rs->EOF)
{
?>
<tr>
<td width="135" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<? $StrName = $rs->Fields['Name']->value;
$StrSec = $rs->Fields['Sec #']->value;
$StrFrom = substr($rs->Fields['From']->value,0,2);
echo "<a target='_blank' href='WorkHistory.asp?name=".$StrName."&sec=".$StrSec."&from=".$StrFrom."'>".$StrName."</a>"; ?>
</font>
</td>
<td width="31" bgcolor="#CCFFFF" align="center">
<font face="Arial" size="1">
<?$StrTemp = $rs->Fields['Zone']->value;
if (substr($StrTemp,0,2) == "nm"
{ ?>
<font color="#FF0000">
<? echo $HREFString.$JavaString.$StrTemp."</A>"; ?>
</font>
<? }Else {
echo $StrTemp;
} ?>
</font>
</td>
<td width="164" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?= $rs->Fields['From']->value ?>
</font>
</td>
<td width="152" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?= $rs->Fields['To']->value ?>
</font>
</td>
<td width="33" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?= $rs->Fields['Width']->value ?>
</font>
</td>
<td width="89" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?
if ($rs->Fields['Last Constructed']->value < strtotime("1/1/1970"
)
{
print "<font color='#FF0000'>1/1/1960</font>";
}
else
{
print date("m/d/Y",$rs->Fields['Last Constructed']->value);
}
//date("m/d/Y",$rs->Fields['Last Constructed']->value) ?>
</font>
</td>
<td width="49" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?
if ($rs->Fields['Last Inspected']->value < strtotime("1/1/1970"
)
{
print "<font color='#FF0000'>1/1/1960</font>";
}
else
{
print date("m/d/Y",$rs->Fields['Last Inspected']->value);
}
//date("m/d/Y",$rs->Fields['Last Inspected']->value) ?>
</font>
</td>
<td width="30" align="center" bgcolor="#CCFFCC">
<font face="Arial" size="1">
<?= $rs->Fields['Last PCI']->value ?>
</font>
</td>
<td width="25" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<? $temp = $rs->Fields['Last Chip Seal'];
if ($temp->value < strtotime("1/1/1970"
)
{
print "<font color='#FF0000'>1960</font>";
}
else
{
print date("Y",$temp->value);
}
/*
if (is_long($rs->Fields['Last Chip Seal']))
{
print "<font color='#FF0000'>N/A</font>";
}
else
{
print date("Y",$rs->Fields['Last Chip Seal']->value);
} */
?>
</font>
</td>
<td width="41" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<? $StrTemp = $rs->Fields['Surface Type']->value;
if ($StrTemp == "GR"
{ ?>
<font color="#FF0000"><b>
<? echo $HREFString.$JavaString2.$StrTemp."</A>"; ?>
</b></font>
<? } else {
echo $StrTemp;
} ?>
</font>
</td>
</tr>
<? $rs->MoveNext();
}
$rs->Close();
$conn->Close();
?>
<tr>
The "Last Chip Seal" date is the one that I have problems with. The "Last Constructed" and "Last Inspected" dates seeem to work fine - there are no blank or null entries in these fields.
Thanks in advance for your help!
I'm pulling information from an Access Database to display on the internet. I have several date fields in the database that may or may not contain dates. When there are no dates I would like the field (in the table) to just be blank. However, I keep getting errors like the following when I encounter blank fields:
Warning: Unsupported variant type: 1 (0x1) in D:\Inetpub\billings\pwe\employee\php_test\display_pci.php on line 156
Several text and integer fields work great. Just a problem with the [blank] date fields.
I have tried to test to see if the field is null (is_null()) and that doesn't seem to work. I have tried to test the length of the field (strlen()) to see if it's shorter than a valid length and can't seem to get that working either. I would really appreciate any help anyone can offer as to how to get the blank entries to display w/o the error messages.
Here is how I connect to the database:
//============================
//Open Database Connection
//============================
$db = 'D:\Inetpub\billings\pwe\data\pwe1.mdb';
$conn = new COM('ADODB.Connection');
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db"

$SQL = "SELECT * FROM [2004_PCI] WHERE [2004_PCI].Name = '".$StrStreetName."'";
//=====================
// FOR DE-BUGGING
//=====================
//echo $SQL."<BR>";
$rs = $conn->Execute($SQL);
if ($rs->EOF)
{
$rs.Close();
$conn.Close();
//Response.Redirect("SelectStreet.asp?Error=yes"

//Response.End
}
else
{
$rs->MoveFirst();
}
And then when I want to display the info:
<? while (!$rs->EOF)
{
?>
<tr>
<td width="135" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<? $StrName = $rs->Fields['Name']->value;
$StrSec = $rs->Fields['Sec #']->value;
$StrFrom = substr($rs->Fields['From']->value,0,2);
echo "<a target='_blank' href='WorkHistory.asp?name=".$StrName."&sec=".$StrSec."&from=".$StrFrom."'>".$StrName."</a>"; ?>
</font>
</td>
<td width="31" bgcolor="#CCFFFF" align="center">
<font face="Arial" size="1">
<?$StrTemp = $rs->Fields['Zone']->value;
if (substr($StrTemp,0,2) == "nm"

<font color="#FF0000">
<? echo $HREFString.$JavaString.$StrTemp."</A>"; ?>
</font>
<? }Else {
echo $StrTemp;
} ?>
</font>
</td>
<td width="164" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?= $rs->Fields['From']->value ?>
</font>
</td>
<td width="152" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?= $rs->Fields['To']->value ?>
</font>
</td>
<td width="33" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?= $rs->Fields['Width']->value ?>
</font>
</td>
<td width="89" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?
if ($rs->Fields['Last Constructed']->value < strtotime("1/1/1970"

{
print "<font color='#FF0000'>1/1/1960</font>";
}
else
{
print date("m/d/Y",$rs->Fields['Last Constructed']->value);
}
//date("m/d/Y",$rs->Fields['Last Constructed']->value) ?>
</font>
</td>
<td width="49" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<?
if ($rs->Fields['Last Inspected']->value < strtotime("1/1/1970"

{
print "<font color='#FF0000'>1/1/1960</font>";
}
else
{
print date("m/d/Y",$rs->Fields['Last Inspected']->value);
}
//date("m/d/Y",$rs->Fields['Last Inspected']->value) ?>
</font>
</td>
<td width="30" align="center" bgcolor="#CCFFCC">
<font face="Arial" size="1">
<?= $rs->Fields['Last PCI']->value ?>
</font>
</td>
<td width="25" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<? $temp = $rs->Fields['Last Chip Seal'];
if ($temp->value < strtotime("1/1/1970"

{
print "<font color='#FF0000'>1960</font>";
}
else
{
print date("Y",$temp->value);
}
/*
if (is_long($rs->Fields['Last Chip Seal']))
{
print "<font color='#FF0000'>N/A</font>";
}
else
{
print date("Y",$rs->Fields['Last Chip Seal']->value);
} */
?>
</font>
</td>
<td width="41" align="center" bgcolor="#CCFFFF">
<font face="Arial" size="1">
<? $StrTemp = $rs->Fields['Surface Type']->value;
if ($StrTemp == "GR"

<font color="#FF0000"><b>
<? echo $HREFString.$JavaString2.$StrTemp."</A>"; ?>
</b></font>
<? } else {
echo $StrTemp;
} ?>
</font>
</td>
</tr>
<? $rs->MoveNext();
}
$rs->Close();
$conn->Close();
?>
<tr>
The "Last Chip Seal" date is the one that I have problems with. The "Last Constructed" and "Last Inspected" dates seeem to work fine - there are no blank or null entries in these fields.
Thanks in advance for your help!