MySQL Forums
Forum List  »  PHP

$mysqli-query does not execute multiple statements
Posted by: Jason Wisdom
Date: May 13, 2021 01:28AM

Hi!
I am trying to execute multiple statements after opening a MySqli connection...the first two execute and the final one does not.
What am I doing wrong?
MySQL version = the last one before 8.0.
Thank you,
Jason

--


$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if(! $conn ){
die('Could not connect: ' . mysqli_error());
}
// This works
$sql = "call spInsertStuff(17, 'John', 'Wilson', 'Spokane', 'US');";
$conn->query($sql);

// This works
$sql = "CALL spSelectOneRow('" . $name . "', '" . $dob . "', '" . $startdate. "', '" . $enddate . "');";
echo $sql;
$result = $conn->query($sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$transactionid= $row['transactionid']; (repeat for all fields)
}
}

// This does NOT work
$sql = "call spInsertStuff(18, 'Jane', 'Wooder', 'South Jersey', 'US');";
$conn->query($sql);



Why doesn't the third query execute? I am getting no errors or warnings on my screen or in error log.

Options: ReplyQuote


Subject
Written By
Posted
$mysqli-query does not execute multiple statements
May 13, 2021 01:28AM


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.