title: Echo all values from mysql column
body: <p>I am trying to echo all the values of 'comment' from a user defined table (<code>$table_name</code>)<br/></p>
  
  <pre><code>$pdo = new PDO('mysql:dbname=db', 'user', 'pass');
  
  $stmt2 = $pdo-&gt;query("SELECT comment FROM '$table_name'");
  
      if ($stmt2-&gt;rowCount() &gt; 0) {
  
          $comments = $stmt2-&gt;fetchAll(PDO::FETCH_NUM);
  
          foreach ($comments as $comment) {
  
              $comm = $comment[0];
              echo $comm;
  
          }
      }
  </code></pre>
  
  <p><br/>However I get this error: </p>
  
  <blockquote>
    <p>Fatal error: Call to a member function rowCount() on a non-object in /FilePath/file.php on line 3</p>
  </blockquote>