title: "Fatal error: Call to a member function fetch_assoc() on a non-object" when using PDO
body: <p>How do I resolve the following error?</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function fetch_assoc() on a non-object
    in index.php on line 27 Call Stack: 0.0000 644064 1. {main}()
    index.php:0</p>
  </blockquote>
  
  <p>This is the code I'm running so far:</p>
  
  <pre><code>$sql = 'SELECT * FROM pm_user WHERE name='.$_SESSION['pmname'].'';
  $result = $pdo-&gt;query($sql);
  $row = $result-&gt;fetch_assoc(); // line 27
  echo $row['img'];
  </code></pre>
  
  <p>Thanks in advance</p>