Hello,
I have a form with a text field (<input name="a1" type="text" size="5">). If a user types "0", "0.0" or "0.00" , I want to insert "0" into my mysql db. If a user leaves the field blank, I want to insert NULL into the db.
However, my code keeps inserting "0" into my db even when the field is left blank. (I echoed out the variable and it's empty - so I don't know why PHP doesn't treat it as NULL).
To check what was happening, I wrote:
if (is_null($a1))
{
echo "a1 is NULL";
}
else echo "a1 is NOT NULL";
As I say, when I echoed out $a1 to double-check, it's empty but the above code keeps saying "a1 is NOT NULL". What am I doing wrong? Any pointers would be appreciated.