title: Fatal error: Call to a member function rowCount() on a non-object
body: <p>I'm using PDO in my login (as instructed previously over sqli), and I have tried the following, but yet I am getting this Fatal Error, and cannot figure out what to give it, so it satisfies the error:</p>
  
  <pre><code>if($query-&gt;rowCount() &gt; 0) 
  {
     // session stuff
     // refresh page
  }
  </code></pre>
  
  <p>Then I tried this: </p>
  
  <pre><code>if($query-&gt;rowCount() == 1) 
  {
     // session stuff
     // refresh page
  }
  </code></pre>
  
  <p>Yet I still get this: <strong>Fatal error: Call to a member function rowCount() on a non-object</strong></p>
  
  <p>Here's is what I started with before the changes:</p>
  
  <pre><code>$count = $query-&gt;rowCount();
  </code></pre>
  
  <p>Lastly, here's a better snippet so you can get an idea of what's involved:</p>
  
  <pre><code>&lt;?php
  include("/scripts/Connections.php");
  
  $email = $_POST['email'];
  $username = $_POST['username'];
  $password = md5($_POST['password'], "DDerehOjhdfDDf$$##%^)-=_/.#$#dkfsj!`~efjkf(*)/)sD");
  $confPassword = md5($_POST['conPassword'], "DDerehOjhdfDDf$$##%^)-=_/.#$#dkfsj!`~efjkf(*)/)sD");
  
  if(isset($email, $username, $password, $confPassword)) {
      if(strstr($email, "@")) {
          if($password == $confPassword) {
              $query = $dbc-&gt;prepare("SELECT * FROM members WHERE username = ? OR email = ?");
              $query = $query-&gt;execute(array(
              $username,
              $email
          ));
  
          $count = $query-&gt;rowCount();
  
          if($count == 0) {
              $query = $dbc-&gt;prepare("INSERT INTO memebers SET username = ?, email = ?, password = ?");
              $query = $query-&gt;execute(array(
                  $username,
                  $email,
                  $password
              )); 
              if($query) {
                  echo "Your account has been registered, you may login!";                
          }           
          }
          else {
              echo "A user already exists with that username/password.";
          }
      }
      else {
              echo "Your passwords do not match!";
          }
  }
  else {
              echo "Invalid email address!";
          }
      }           
  ?&gt;
  </code></pre>
  
  <p>Can anyone point where I'm going wrong here. This is my only error this is being thrown. </p>