Dealing with "commands out of sync" in prepared statements


show more Dealing with "commands out of sync" in prepared statements provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP show less
please wait ...

Dealing with "commands out of sync" in prepared statements

In the previous video, we created a transaction to transfer money from one account to another But there was nothing to prevent the transaction from going ahead if the payer ran out of funds. This is mysqli_check_balance.php, which you can find in the chapter six, 06_05 folder of the exercise files. This updates the previous script to roll back the transaction if the balance in the outgoing account falls below zero.

But adding in this extra step results in MySQLi generating a fatal error. Before examining the code, let's take a look at the error message by loading the page into a browser. It says that the fatal error is a call to a member function fetch_assoc on a non-object on line 83. So let's examine the code to see what's happening on line 83. We need to go all the way down to the bottom of the page, and line 83 is the beginning of the while loop that displays the balances.

And that balances query is executed here on line 59. And it's got nothing to do with the transaction or with rol...

Dealing with "commands out of sync" in prepared statements
Video duration: 5m 26s 3h 47m Intermediate

Viewers:

Dealing with "commands out of sync" in prepared statements provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP

Subject:
Developer
Software:
PHP
Author:
please wait ...