MySQL Forums
Forum List  »  PHP

Update mySQL row with PHP using sproc
Posted by: Arthur Chan
Date: June 03, 2020 01:05AM

New some help to trap and return boolean value on successful or failed update.
The PHP is not returning any values, blank screen, no error messages.

Person ( personId Int, addressL1 varchar(50))
when I update the address I need to return a 1 or -1 value to be displayed in Firefox. The value will be passed onto a Java app.

Here is the PHP:
<?php
header("Content-type:application/json; charset=UTF-8");
$con = mysqli_connect("server", "user", "pwd", "instance");
mysqli_set_charset( $con, "utf8mb4" );
if (mysqli_connect_errno($con)) {
   echo "Failed to connect to MySQL: " .mysqli_connect_error();
   exit();
} 
$personId = $_POST['personId'];
$addressL1= $_POST['addressL1'];
$result = "call sp_updatePerson ('$personId','$AddressL1')";

if($result) {
    return true;
} else {
    return false;
}
mysqli_close($con);
?>


And here is the sproc:
UPDATE Person set addressL1=addressL1
WHERE personId = personId;

In Firefox, I'd execute something like this:
https://forums.mysql.com/updateperson.php?personId=1234&addressL1=123 testing;

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.