title: How to show column values with PDO prepared statement
body: <p>I am new to PDO, but cant seem to work how to return values</p>
  
  <pre><code>$stmt = $pdo-&gt;prepare('SELECT * FROM categories WHERE categories_url = ?');
  $stmt-&gt;execute([$url]);
  if($stmt-&gt;fetchColumn()&gt;0) {
      $row = $stmt-&gt;fetch();
      echo $row['categories_name'];
      echo 'test';
  }
  </code></pre>
  
  <p>The 'test' echos ok, but the $row values dont show. I tried <code>print_r($row)</code> too, and nothing shows. I thought I needed to set the $row variable using the fetch() method, is this not right? What is wrong here?</p>
  
  <p>** UPDATE **</p>
  
  <p>I removed the if statement, for fetchColumn, and it works, why is that? Does it matter if fetchColumn method comes before fetch()?</p>
  
  <p>If so, how do you set the $row variable only if there are results?</p>