June 2017
Intermediate to advanced
536 pages
9h 49m
English
Much like selecting and inserting, we can also use the prepare(), bind_param(), and execute() methods to handle record updating, as follows:
<?phptry { // Report on all types of errors mysqli_report(MYSQLI_REPORT_ALL); // Open a new connection to the MySQL server $mysqli = new mysqli('127.0.0.1', 'root', 'mL08e!Tq', 'sakila'); // Prepare some teat address data $address = 'The new street'; $addressId = 600; // Prepare an SQL statement for execution $statement = $mysqli->prepare('UPDATE address SET address = ? WHERE address_id = ?'); // Bind variables to a prepared statement as parameters $statement->bind_param('si', $address, $addressId); // Execute a prepared Query $statement->execute(); // Close a prepared statement $statement ...