I’m trying to insert multiple rows but I continue getting an sqlerror and cannot for the life of me figure out why.
echo '"'.$thequery.'"';
$sql = mysql_query($thequery) or die(mysql_error());
return "SUCCESS";
$thequery gets printed out as:
“INSERT INTO thistable (rank, change, reqID, vanID) VALUES (1,’PICKUP’,28,1),(2,’PICKUP’,29,1),(3,’DROPOFF’,28,1),(4,’DROPOFF’,29,1)”
and the error:
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 ‘change, reqID, vanID) VALUES (1,’PICKUP’,28,1),(2,’PICKUP’,29,1),(3,’DROPOFF’,28′ at line 1
Thanks in advanced.
CHANGEis a reserved word in MySQL. Rename the column or enclose the identifier in backticks.Besides, you seem to have a typo in the
VALUESpart: in(1,'PICKUP,'28,1),(2,'PICKUP,'29,1),, the,'should be',.