mysqli multi_query works, but not what I have expected. Please look at my example, it is as simple as I can render the underlying problem.
I was hoping @flag would return true if connected and updated row, else return false.
Also, when I try to json_encode($response) the array and run the PHP in Firefox, it returns this error:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
<?php
header("Content-type:application/json; charset=UTF-8");
$conn = mysqli_connect("localhost", "usr", "pwd", "instance");
mysqli_set_charset( $conn, "utf8mb4" );
if (mysqli_connect_errno($conn)) {
echo "Failed to connect to MySQL: " .mysqli_connect_error();
}
$personId = $_REQUEST['personId'];
$pAddrL1 = $_REQUEST['pAddrL1'];
$result = $conn->multi_query("CALL sp_updCompany('$personId','$pAddrL1', @flag); SELECT @flag");
if($result==1) {
echo('Updated data flag = '.$result);
$response = ["flag"=>$result];
echo json_encode ($response);
} else {
$response = ["flag" =>-1];
echo json_encode ($response);
}
mysqli_close($conn);
?>