What is wrong with this sql? It fails in php but doesn't fail in phpmyadmin!


$connection=mysql_connect("localhost", "root", "");
if(!$connection) {
	die('Could not connect: ' . mysql_error());
} else {
	mysql_select_db("test", $connection) or die('Could not select the table.');

	$sql.="SET AUTOCOMMIT=0;\n";
	$sql.="INSERT INTO table1 (id, name) values (1, 'person1');\n";
	$sql.="INSERT INTO table2 (id, name) values (2, 'person2');\n";
	$sql.="INSERT INTO table3 (id, name) values (3, 'person3');\n";
	/*echo "<pre>";
	echo $sql;exit;*/
	if($runSql) {
		echo "Done";
	} else {
		echo "Failed";
Member Avatar


I thought that you could only run one query at a time in php. Have you checked the php manual for mysql functions?

commented: Thanks +2

mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier .

Source: http://in2.php.net/function.mysql-query

commented: Thanks +2

ok. I'll find different way then. Thanks guys.