Multiple INSERTs in mysql_query()
Posted: Tue Aug 10, 2004 1:45 pm
I want to insert more than one row into a table. I can do the for loop but Im trying to avoid querying many times. But Im not able to get this to work:
Any idea what to do ? I tried adding \r\n after the semi colon but no luck.
Thanks
Code: Select all
mysql_select_db("test");
$sql="
INSERT INTO `test1` VALUES ('q','w','e','5');
INSERT INTO `test1` VALUES ('q','w','e','6');
INSERT INTO `test1` VALUES ('q','w','e','7');
INSERT INTO `test1` VALUES ('q','w','e','8');
";
$res=mysql_query($sql);
if (!$res) echo $sql.'<br>'.mysql_error();Thanks