Hi guys, new to the forum and learning PHP but hoping to stick around for a long time. 🙂
I've got a book I'm getting through and and after some very good and successful tutorials I attempted to create a php page that can edit users profile.
Part of the code is below (if someone needs all of it that's fine to provide but thought a snippet of where the problem line is and after it would be easier), and then underneath that is the error, the page itself is accessed through view_users.php
// Retrieve the user's information:
$q = "SELECT first_name, last_name, email FROM users WHERE user_id=$id";
$r = @mysqli_query ($dbc, $q);
if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form.
// Get the user's information:
$row = mysqli_fetch_array ($r, MYSQLI_NUM);
// Create the form:
echo '<form action="edit_user.php" method="post">
<p>First Name: <input type="text" name="first_name" size="15" maxlength="15" value="' . $row[0] . '" /></p>
<p>Last Name: <input type="text" name="last_name" size="15" maxlength="30" value=' . $row[1] . '" /></p>
<p>Email Address: <input type="text" name="email" size="20" maxlength="40" value=' . $row[2] . '" /></p>
<p><input type="submit" name="submit" value="Submit" /></p>
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
</form>';
} else { // Not a valid user ID.
echo '<p class="error">This page has been accessed in error.</p>';
}
mysqli_close($dbc);
include ('footer.html');
?>
error: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /studhome/0/0812578/public_html/edit_user.php on line 89
This page has been accessed in error.
...I wish I could say I've tried everything as I probably haven't but I have no idea what the error is for. I'm guessing it is needing there to be only one user but more/none are coming up?
Thanks for any help.