title: How can I resolve "Fatal error: Call to a member function query() on a non-object"?
body: <p>I have this script that I'm using, and on the index.php it's giving me this error from the code on line 15. </p>
  
  <blockquote>
    <p>Fatal error: Call to a member function query() on a non-object</p>
  </blockquote>
  
  <p>This is the entire index.php:</p>
  
  <pre><code>ob_start();
  session_start();
  if(file_exists("./install/install.lock"))
  {
      print "You must delete install.php";
      exit;
  }
  elseif(file_exists("./install/update.lock"))
  {
      print "You must delete update.php";
      exit;
  }
  
  $getuser = $os_DB-&gt;query("SELECT * FROM accounts WHERE id='".$_SESSION['userid']."'");
  $ui      = $os_DB-&gt;fetch($getuser);
  
  //Check if IP is banned
  $ip = $_SERVER['REMOTE_ADDR'];
  $checkbanned  = $os_DB-&gt;query("select * from banned where ip_addr='$ip'");
  
  while($reason = $os_DB-&gt;fetch($checkbanned))
  {
      if($os_DB-&gt;num($checkbanned) != 0) 
      {
          header("Location: site/banned");
      }
  }
  //check if ip is a proxy
  require_once('includes/classes/ProxStop.php');
  
  // Perform Lookup
  $result = $ProxStop-&gt;proxyLookup($ip,$ref);
  
  // The lookup failed, print the error message.
  if($result===false)
  {
      //echo 'The lookup failed with the error "'.$ProxStop-&gt;errors['code'].': '.$ProxStop-&gt;errors['msg'].'"';
  }
  
  // The IP is a proxy
  elseif((int)$result-&gt;score&gt;1)
  {
      $os_DB-&gt;query("INSERT INTO banned VALUES ('$ip')");
      $os_DB-&gt;query("UPDATE accounts SET level=2 WHERE ip='$ip'");
      header("Location: site/banned");
  }
  //Save Referral
  if($_GET['ref'] != "")
  {
      $ref = $_GET['ref'];
      setcookie("Referral", $ref, time()+3600, "/", $domain);
  }
  if(!defined("OS_THEME"))
  {
      print "This site has no theme defined";
      die();
  }
  else
  {
      require_once($root . 'functions/functions.php');
      if($settings['captcha_type'] == 3)
      {
          require "securimage/securimage.php";
          $securimage = new Securimage();
      }
      include($root . 'header.php');
      include($root . 'action.php');
      include($root . 'footer.php');
  }
  ?&gt;
  </code></pre>
  
  <p>I'm not a programmer so I'm not sure what to do with this. I've read through other posts with issues similar but I don't know what to do.</p>