mysqli_stmt_num_rows, mysqli_stmt_execute and mysqli_store_result
<p>I have the following function which is supposed to check if a new email address to be added into the database is already in there.</p>

<pre><code>function duplicate_email($email_y){
    $dbCon = db_connect();
    $sql = "SELECT email FROM users WHERE email = ?";
    if ($stmt = mysqli_prepare($dbCon, $sql)) {

        mysqli_stmt_bind_param($stmt, "s", $email_y);
        mysqli_stmt_execute($stmt);
        //mysqli_store_result($dbCon);
        $rows = mysqli_stmt_num_rows($stmt);

        if($rows == 1){
            mysqli_stmt_close($stmt);
            mysqli_close($dbCon);
            return true;
            }
        else{
            mysqli_stmt_close($stmt);
            mysqli_close($dbCon);
            return false;
        }     
    }
}
</code></pre>

<p>This is where I use it:</p>

<pre><code>if(duplicate_email($email) == true){
    echo 'Email [ '.$email.' ] seems to be already used';
}
</code></pre>

<p>The problem is that is does not detect, I've tested on an email address that is in the database and it fails, it passes over like its not there. 
Any thoughts where it fails?
thx</p>
