Execute returns True when it is completed successfully, but if that is not enough for you, you can also check the affected lines :
$query = "UPDATE user SET password = ? WHERE email = ?"; if($stmt = $conn->prepare($query)) { $stmt->bind_param('ss', $pwd, $userEmail); if ($stmt->execute()) { //query with out errors: printf("rows updateds: %d\n", $stmt->affected_rows); } else { //some error: printf("Error: %s.\n", $stmt->error); } }
The second check you can do is check that exactly one row has been updated:
if($stmt = $conn->prepare($query)) { $stmt->bind_param('ss', $pwd, $userEmail); if ($stmt->execute() and $stmt->affected_rows == 1) {
source share