Sorry stuck again!
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\test_council_site\login.php on line 52
can someone also explain this error message to me
<?php // This page will allow users to log into the site
// get the databse settings file and estblish a connection.
require_once ('../mysqli_connect.php');
// set the page title variable $page_title
$page_title = 'User Login';
// get the page header file from the includes directory
include ('includes/header.html');
// Check if the form has been submitted:
if (isset($_POST['submitted'])) {
$errors = array(); // Initialize an error array.
// check the email address is present
if (empty($_POST['email_address'])) {
$errors[] = 'You forgot to enter your email address.';
} else {
$email_address = mysqli_real_escape_string ($dbc, $_POST['email_address']);
}
// check the password
if (empty($_POST['password'])) {
$errors[] = 'You forgot to enter your password.';
} else {
$password = mysqli_real_escape_string ($dbc, $_POST['password']);
}
// check password and email_address have variables assigned
if ($email_address && $password){
// submit the values in a query to the mysql database
$q = "SELECT user_id, first_name, user_level FROM user_details WHERE (email='$email_address' AND pass=SHA1'$password'))";
//run the query or provide an error message as to why it wasnt run.
$r = @mysqli_query ($dbc, $q);
// if mysql_error display the Query+Error
if(mysql_error()) exit($q.'<br>'.mysql_error());
//check a match was made
if (mysqli_num_rows($r) == 1) {
// register the values to the sessiobn and redirect the user to the homepage.
$_SESSION = mysqli_fetch_array ($r, MYSQLI_ASSOC);
// free all memory associated with the result identifier
mysqli_free_results($r);
//close the database connection
mysqli_close($dbc);
// re direct using the header command
header('Location: http://localhost/test_council_site/index.php');
// end the script
exit();
} else { // No match was made.
echo '<p class="error">Either the email address and password entered do not match those on file or you have not yet activated your account.</p>';
}
} else { // If everything wasn't OK.
echo '<h1>Error!</h1>
<p class="error">The following error(s) occurred:<br />';
foreach ($errors as $msg) { // Print each error.
echo " - $msg<br />\n";
}
echo '</p><p>Please try again.</p><p><br /></p>';
}
mysqli_close($dbc);
} // End of SUBMIT conditional.
?>
<h1>Login</h1>
<p>Your browser must allow cookies in order to log in.</p>
<form action="login.php" method="post">
<fieldset>
<p>Email Address: <input type="text" name="email_address" size="20" maxlength="80" value="<?php if (isset($_POST['email_address'])) echo $_POST['email_address']; ?>" /> </p>
<p><b>Password:</b> <input type="password" name="password" size="20" maxlength="20" /></p>
<div align="center"><input type="submit" name="submit" value="Login" /></div>
<input type="hidden" name="submitted" value="TRUE" />
</fieldset>
</form>
<?php // Include the HTML footer.
include ('includes/footer.html');
?>