title: Can't retrieve PDO results outside of function
body: <p>Probably the product of lack of sleep but I just can't figure this out, I've been experimenting and searching for far too long at this point so figured all I could do now is ask for help.</p>
  
  <p>I have many pages that use data from a database and to condense the code a little I wanted to contain the database pulls within a function:</p>
  
  <pre><code>function dbh($sql, $arr){
      global $dbh;
      $stm = $dbh-&gt;prepare($sql);
      $stm-&gt;execute($arr);
      $row = $stm-&gt;fetch();
      return $row;
  }
  </code></pre>
  
  <p>But it just won't return anything for me. The function is called on the page like so:</p>
  
  <pre><code> $row = dbh('SELECT * FROM ' . $pfx . '_user WHERE email = ? LIMIT 1', array($vld_fgt));
  
  
  $usr = $row['user_id'];
  $sup = $row['sign_up'];
  $eml = $row['email'];
  
  echo $usr;
  </code></pre>
  
  <p>I've tried many different things but just can not get it to work. Is this possible, and if so, how do I get it to give me the results so I can use them outside of the function?</p>