Michael
Michael

Reputation: 6405

php mysql , count rows

I have the following script :

 $queryUniqueEmail = "SELECT email FROM Applicant WHERE email = '".base64_encode($email)."';";
  $resultUniqueEmail = $db->query($queryUniqueEmail);
  $resultRowsEmails = $resultUniqueEmail->numRows();
if($resultRowsEmails == 0)
    $db->query($query);
  }
$resultRowsEmails->free();
}
$db->close();
echo "Finish!";

Basically verifies a an email is existing already in the db and if so the insert operation is skipped . Howver I'm getting the following error when I run it

PHP Fatal error:  Call to undefined method mysqli_result::numRows() in /var/www/html/asd.php

How can I fix it ?

Upvotes: 1

Views: 1233

Answers (2)

chris
chris

Reputation: 4026

I think you're looking for num_rows

Upvotes: 0

Dan Grossman
Dan Grossman

Reputation: 52372

There is no method called numRows in the mysqli_result class.

There is a property, num_rows

$resultRowsEmails = $resultUniquEmail->num_rows;

http://php.net/manual/en/class.mysqli-result.php

Upvotes: 2

Related Questions