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.
null date field
Moderator: General Moderators
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'";
}