Setting variable's database value to NULL instead of empty string
问题 In my SQL database there're many fields like this: Field Type:Text Null:Yes Default:NULL My INSERT looks like this: INSERT INTO tbl (col,col,col,...) VALUES ('val','val','val',...) Now, those quotes in my INSERT statement's values are inserting '' (empty string) in to the database when what I really want is nothing (NULL). So I tried if (isset($_POST['title'])) {$newTitle = mysql_real_escape_string(trim($_POST['title']));} else {$newTitle = NULL;} and that just inserts 'NULL' - the string