title: How to get mysql_num_rows with PDO?
body: <p>How can I easily get the number of rows returned with "<code>SELECT *</code>" SQL-query?</p>
  
  <pre><code>function valid_credentials($db,$name,$pw) {
      try {
  
      $sth = $db-&gt;prepare("SELECT * FROM ib_members WHERE name=:val AND pw=:val2");
      $sth-&gt;bindValue(":val",$name);
      $sth-&gt;bindValue(":val2",$pw);   
      $sth-&gt;execute();
  
  
      $numrows = $sth-&gt;fetchColumn();
  
      return $numrows;
  
      } catch (PDOException $e) {
  
          return $e-&gt;getMessage();
  
      }
  }
  </code></pre>
  
  <p>That returns 14, which is definately not the number of rows returned, but it's the ID that  the first row has.</p>