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? Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.