MySQL Forums
Forum List  »  PHP

Re: Update mySQL row with PHP using sproc
Posted by: Arthur Chan
Date: June 11, 2020 10:25PM

Thanks Peter, I read the articles, they are helpful and everything works. I just wanted you to have a look at the PHP.

After several attempts, I found array_push() will populate the array for JSON, and Firefox displays it as expected. Now I can download the value to JavaFX
<?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();
} 
$coyId	= $_REQUEST['personId'];
$cAddrL1	= $_REQUEST['pAddrL1'];
$result = $conn->multi_query("CALL sp_updCompany('$personId','$pAddrL1', @flag); SELECT @flag");

$response = array();
if($result) {
    /** this works **/
    array_push(($response), array('flag'=>$result));
    echo json_encode($response);
} else {
    array_push(($response), array('flag'=>-1));
    echo json_encode ($response);
}		

mysqli_close($conn);
?>

Options: ReplyQuote




Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.