slate Posted April 24, 2003 Share Posted April 24, 2003 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? Link to comment https://forums.phpfreaks.com/topic/393-phpmysql-not-inserting-null-values/ Share on other sites More sharing options...
slate Posted April 24, 2003 Author Share Posted April 24, 2003 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. Link to comment https://forums.phpfreaks.com/topic/393-phpmysql-not-inserting-null-values/#findComment-1325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.