0

Hi,

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

Thanks

<?php
$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="BEGIN;\n";
	$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";
	$sql.="COMMIT;";
	/*echo "<pre>";
	echo $sql;exit;*/
	$runSql=mysql_query($sql);
	
	if($runSql) {
		echo "Done";
	} else {
		echo "Failed";
	}
}
?>
3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by veledrom
1

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

Votes + Comments
Thanks
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.