Ive adapted this script and it seems to work very well, apart from the following error
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\phpfinal\edit_usersllph.php on line 54
I think I understand what the line is trying to do. Larry explains it very well in the book. So I dont get why its going wrong.
Can anyone help? It doesnt stop the script and the changes are made.
Here is the code again.
$q = "SELECT customerID, cardholdersaddress FROM llphorders WHERE customerID = $id AND cardholdersaddress = $ln";
$r = @mysqli_query($dbc, $q);
if (mysqli_num_rows($r) == 0) {
// Make the query:
$q = "UPDATE llphorders SET cardholdersaddress='$ln' WHERE customerID= $id LIMIT 1";
$r = @mysqli_query ($dbc, $q);
if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.
// Print a message:
echo '<p>The user has been edited.</p>';
} else { // If it did not run OK.
echo '<p class="error">The user could not be edited due to a system error. We apologize for any inconvenience.</p>'; // Public message.
echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; // Debugging message.
}
} else { // Already registered.
echo '<p class="error">The email address has already been registered.</p>';
}
} else { // Report the errors.
I hope my changes look ok!
Bill