Jump to content

How to get data from SQL query that uses COUNT with MySQLi?


Recommended Posts

The following code is giving an error:

 

$check_email_DB = mysqliCOE('zyquo_emotico');
$sanitized_email=mysqli_sanitize($check_email_DB, $register_email);
$result = $check_email_DB->query("SELECT COUNT(email) FROM user WHERE email='$sanitized_email'");
$number_rows = $result->fetch_assoc();
if($number_rows!=1){
$error[18]=1;
}
else{
$error[18]=0;
}

 

This is producing a non-object error:

Fatal error: Call to a member function fetch_assoc() on a non-object.

 

What's wrong with the above? I pretty much copied it right off the manual on php.ner

 

Is there a better way to get the results from a COUNT query in MySQLi?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.