Page 1 of 1

[SOLVED] - Spot the SQL Syntax Error

Posted: Wed Aug 22, 2007 12:21 pm
by iknownothing
Hey Guys, I have the following, and can't for the life of me, find the SQL syntax error, can anyone see it...

Code: Select all

$sql = mysql_query("INSERT INTO news_events (id, title, posted, description, is_event, when, where) VALUES ('', '$title', '$posted', '$description', '$is_event', '$when', '$where')");
		if (!$sql){
			echo mysql_error();
		}
Thanks.

Posted: Wed Aug 22, 2007 12:37 pm
by CoderGoblin
"where" should be a reserved word and should not be used as a column name. Is the id an integer... you are saving as a string.

When posting things like this and you have an error message can you post it as well.

Posted: Wed Aug 22, 2007 2:28 pm
by timvw
btw, i would expect where to be a special value... thus it would need proper escaping

Posted: Wed Aug 22, 2007 3:14 pm
by iknownothing
yeah, I could have changed its name, but that seemed to hard (lazy), so i escaped it instead.