Catchable fatal error: Object of class variant could not be
Posted: Wed Mar 16, 2011 2:03 pm
I am trying some basic code, but am producing the error message in the subject line above. It is returning this error because the result is a NULL value; however, I have tried using empty and is_null and it still produces the same error. Here is some relevant code:
The error occurs on the echo $strOldTariffCode; line.
I have replaced the is_null with empty and it produced the same error. I have also changed it to if (trim($strOldTariffCode) == NULL) and it still produces a seperate error of:
Warning: trim() expects parameter 1 to be string, null given
Any ideas on how to get past this? Basically, I just want the result ot be a blank value if it is a NULL value
Code: Select all
<?php
require("dbQS.php");
$strPart = CheckPost('hidPart', '');
$strCountryOfOrigin = CheckPost('txtCountryOfOrigin', '');
$intPO = CheckPost('hidPO', '');
$strMfg = CheckPost('hidMfg', '');
$strTariffCode = trim(CheckPost('txtTariffCode', ''));
$ssql = "SELECT TariffCode, ID FROM InventoryMaster1 WHERE ([PART #] = '$strPart')";
$rs = $dbc->execute($ssql);
if (!$rs->EOF)
{
$strOldTariffCode = $rs['TariffCode'];
$intID = $rs['ID'];
}else{
$strOldTariffCode = "";
$intID = "";
}
$rs->close;
$rs=null;
if (is_null($strOldTariffCode))
{
$strOldTariffCode = "Test";
}
echo $strOldTariffCode;
I have replaced the is_null with empty and it produced the same error. I have also changed it to if (trim($strOldTariffCode) == NULL) and it still produces a seperate error of:
Warning: trim() expects parameter 1 to be string, null given
Any ideas on how to get past this? Basically, I just want the result ot be a blank value if it is a NULL value