Jump to content


Photo

PHP/Mysql not inserting null values!


  • Please log in to reply
1 reply to this topic

#1 slate

slate
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 April 2003 - 09:47 PM

In this piece of a line of code:

$result = sql_query(\"INSERT INTO map_points VALUES (\'$point_id\', \'$point_title\', \'$point_desc\', etc...


it $point_title is empty (null) in the form, and the default value is NULL, why is it being inserted as 0 into the database?

#2 slate

slate
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 April 2003 - 10:24 PM

Figured it out myself...
There\'s a bug in mysql (according to mysql.com) so I have to do this:

$valsToInsert = \"\";

if ($point_id != \"\")
{
$valsToInsert = $valsToInsert . \"\'$point_id\'\";
}
else
{
$valsToInsert = $valsToInsert . \"NULL\";
}

for each $string i need to check it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users