title: PHP prepared statements - check if a value already exists
body: <p>I am trying to do a check on a value (email), to determine if it already exist in the db. This should be done using prepared statements. What is the best way for doing this? My solution is this (which is wrong):</p>
  
  <pre><code>$mysqli = connectToDB();
  $getEmail = $mysqli-&gt;prepare('SELECT * FROM users WHERE email=?') or die('Couldn\'t check the email');
  $getEmail-&gt;bind_param('s', $email);
  $getEmail-&gt;execute();
  $countRows = $getEmail-&gt;num_rows;
  print $countRows;
  </code></pre>
  
  <p>It always prints out 0 even though the email aready exists in the db.</p>