SQL Not null和php =或false

I have a loop that inserts descriptions and thumbnails into a table, but not all the items in the loop have descriptions and thumbnails. I didn't think this was a problem, but sql won't insert it, unless they have a value. I thought it might be cause by the not null thing, so i tried to change "null" to "yes".

I set it to print out the executed query and the mysql error:

Query: INSERT INTO experiments (title, dir, desc, thumbnail) VALUES('3dbox', '3dbox', '', '')

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, thumbnail) VALUES('3dbox', '3dbox', '', '')' at line 1

I've also tried this:

$d = @file_get_contents("/experiments/$sites[$i]/desc.txt") or false;

but that doesn't work either, as you can see in the query.

desc is reserved in mysql and will have to be identified as:

INSERT INTO experiments (title, dir, `desc`, thumbnail) VALUES('3dbox', '3dbox', '', '')

desc is a reserved word in Mysql. Hence, the error. You would need to change the column name to something else, or access it with backticks like this,

INSERT INTO experiments (title, dir, `desc`, thumbnail) VALUES('3dbox', '3dbox', '', '')

Here's the manual for reserved words.

You can not use "desc" as a column name because is a reserved word: http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html, you need to escape it: try changin your query to this:

INSERT INTO experiments (title, dir, `desc`, thumbnail) VALUES('3dbox', '3dbox', '', '');