title: Call to a member function rowCount() on a non-object
body: <p>Im having a problem with my query. I recently switched to PDO, which is kind of new to me. Now i need to use JOIN in my query to get data from another table without making two executions.</p>
  
  <p>Problem is, i get this error:</p>
  
  <pre><code>Call to a member function rowCount() on a non-object
  </code></pre>
  
  <p>I don't understand what the problem is. This is how my code looks like:</p>
  
  <pre><code>  $friends_string = "SELECT * FROM `friends` as F, `users` as U WHERE `F.userID` = '$sess_user' AND `F.request` = '0' AND `F.friendID` = 'U.id'";
    $friends = $db-&gt;query($friends_string);
    if ($friends-&gt;rowCount() &gt; 0) {
  
  while($row = $friends-&gt;fetch(PDO::FETCH_ASSOC)) {
      echo "&lt;br /&gt;&lt;a href='profile.php?id={$row["id"]}'&gt;{$row["friendID"]}&lt;/a&gt;";
    }
  
  } else {
      echo "no Friends";
  }
  </code></pre>
  
  <p>Or for short, just the query:</p>
  
  <pre><code>SELECT * FROM `friends` as F, `users` as U WHERE `F.userID` = '$sess_user' AND `F.request` = '0' AND `F.friendID` = 'U.id'
  </code></pre>
  
  <p>What I want is, get all rows from friends where userID is session and request is 0. But then i want to get the ID of those friends in users so i can make a link to their profile. Note the <code>$row["id"]</code></p>
  
  <p>I appreciate any feedback, doesn't have to answer my questions, if you note any problem please comment it. Thanks!</p>