title: PDO Function setFetchMode
body: <p>Hello i was trying to make function with PDO but getting error (new to PDO) here is my code</p>
  
  <pre><code>    function mail_id($mail){
      global $host, $dbname, $user, $pass;
      $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
      $STH = $DBH-&gt;query("select count(from) from messages where from = '$mail'");
      $STH-&gt;setFetchMode(PDO::FETCH_ASSOC);
      $row = $STH-&gt;fetch();
      return $row;
  }
  </code></pre>
  
  <p>i want to count row FROM and here is the out put i was trying</p>
  
  <pre><code>$mail=mail_id($userid);
  if (0&lt;count($mail['to_viewed'])) {echo "green";} else {echo "gray";}
  </code></pre>
  
  <p>this is the error </p>
  
  <pre><code>Call to a member function setFetchMode() on a non-object
  </code></pre>
  
  <p>please help thx</p>