title: Fatal error: Call to a member function query() on a non-object in
body: <p>I am using pdo and I have set the connection string in a config file such as </p>
  
  <pre><code>$db = new PDO("mysql:host=localhost;dbname=mydbname", 'root', 'pass');
  </code></pre>
  
  <p>I have this query in a class , in a method/function </p>
  
  <pre><code>$query = $db-&gt;query("select aUsername,aPassword,aOnline,aLastlogin from tbl_admins where aUsername = '$username'");
  </code></pre>
  
  <p>and when I run my site I get that error. is it possible that the $db object is not global?</p>