Why am I getting this PHP/MySQL error?

Spazz

New member
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\Shop\sub_thank.php on line 8

here is my code.

<?php
$email = $_POST['email'];
require_once ('mysqli_connect.php');
// Make the query:
$q = "SELECT email FROM subscribers WHERE email=$email LIMIT 1";
$r = @mysqli_query($dbc, $q);
// If the email is already in the database then return response and quit
if (mysqli_num_rows($dbc) == 1){
echo '<p You are already registered! </p>';
exit();
}
else{
$q = "INSERT INTO subscribers Values ($email)";
$r = @mysqli_query ($dbc, $q);
if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

echo 'Thank you for subscribing!';
}
}

?>
tried if (mysqli_num_rows($r) == 1){

and it still gives the same warning.
 
Back
Top