I keep getting this error and can’t figure out the issue. Any help would be appreciated. Thanks.
The sql – "INSERT INTO practices (order,name,url) VALUES ('1','Business & Corporate Law','business-corporate-law')"
Error: 1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order,name,url) VALUES ('1','Business & Corporate Law','business-corporate-law')' at line 1
Here is the php:
$sql = "INSERT INTO ".$table." (".$cols.") VALUES (".$vals.")";
$result = mysql_query($sql);
if(!$result){die('Error: ' . mysql_errno() . mysql_error());}
with $table as “practices”
with $cols as “order,name,url”
with $vals as “‘1′,’Business & Corporate Law’,’business-corporate-law'”
orderis a keyword within SQL, so if you use it as a column name (or identifier in general) you have to wrap it like the following: