I have a php file which performs a series of insert queries. If any of the queries generates an error, I would like to return the error message and query string and roll back all the queries
So far I have this:
mysql_query("SET autocommit=0;");
mysql_query("BEGIN;");
$sql ="SOME MALFORMED QUERY";
mysql_query($sql);
if(mysql_error()){
mysql_query("rollback;");
$arr = array("returnCode" => 0, "returnMessage" => "Query failed: " .$sql. mysql_error());
echo json_encode($arr);
die();
}
However, In javascript all I'm seeing returned in the return message JSON field is 'Query failed: '. Any idea why this is?