A few notes:
NULL != ''
If your database contains an empty string, you cannot find that by looking for NULL:
SELECT FROM table WHERE field=NULL;
is different from
SELECT FROM table WHERE field="";
and
if ($variable) does NOT check to see if there is a value in $variable, it only checks wether it contains something other than zero. If $variable is not defined, this line will give an error.
look at this:
error_reporting(E_ALL);
if (isset($var))
{
echo 'var set<BR>';
}
else
{
echo 'var not set<BR>';
}
if (empty($var))
{
echo 'var is empty<BR>';
}
else
{
echo 'var is not empty<BR>';
}
if ($var)
{
echo 'var "is"<BR>';
}
else
{
echo 'var "is" not<BR>';
}
try it out without defining $var, then with
$var=0;
and then with
$var=1;
you'll see different answers every time.