I’m trying to insert multiple rows into a MySQL db. The code I’ve been using is this:
<?
mysql_connect ('localhost', 'USERNAME', 'PASSWORD') ;
mysql_select_db ('DATABASE');
$sql = "INSERT INTO `php_blog` ( `id` , `timestamp` , `title` , `entry` ) VALUES ( '', '123456789', 'today', 'test' );INSERT INTO `php_blog` ( `id` , `timestamp` , `title` , `entry` ) VALUES ( '', '123456789', 'today', 'test' );INSERT INTO `php_blog` ( `id` , `timestamp` , `title` , `entry` ) VALUES ( '', '123456789', 'today', 'test' );";
$result = mysql_query($sql) or
print ("Can't insert rows into table 'php_blog'.<br />" . $sql . "<br />" . mysql_error());
mysql_close();
?>
And this is the error I get:
Can't insert rows into table 'php_blog'.
INSERT INTO `php_blog` ( `id` , `timestamp` , `title` , `entry` ) VALUES ( '', '123456789', 'today', 'test' );INSERT INTO `php_blog` ( `id` , `timestamp` , `title` , `entry` ) VALUES ( '', '123456789', 'today', 'test' );INSERT INTO `php_blog` ( `id` , `timestamp` , `title` , `entry` ) VALUES ( '', '123456789', 'today', 'test' );
You have an error in your SQL syntax near ';INSERT INTO `php_blog` ( `id` , `timestamp` , `title` , `entry` ) VALUES ( '', ' at line 1
Help?