Page 1 of 1

null date field

Posted: Tue Oct 26, 2004 7:01 am
by nikko50
Hello,
I have a date field with a default of NULL. If a user enters a date and then decides to update that date field, how can I set it back to NULL?? I tried
$charged = 'NULL';

$query= "UPDATE customers SET charged= '$charged'
WHERE orderid='$orderid'";

But that just sets the field to 0000-00-00. Why is it doing that when the default is set to NULL.

Posted: Tue Oct 26, 2004 10:46 am
by timvw
that is because 'NULL' is not the same as NULL

Code: Select all

if ($charged == 'NULL')
{
    $query = "UPDATE customers SET charged = NULL";
}
else
{
    $query = "UPDATE customers SET charged = '$charged'";
}