title: Fatal error: Call to a member function close() on a non-object. MySQLi issue
body: <p>I have been getting the following error when I uploaded to a live server. It works OK on localhost which I thought was strange.</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function close() on a non-object....</p>
  </blockquote>
  
  <p>The line it refers to</p>
  
  <pre><code>$stmt-&gt;close();
  </code></pre>
  
  <p>The connection to the DB</p>
  
  <pre><code>$connection=new mysqli($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS,$DB)or die(mysqli_error($connection));
  </code></pre>
  
  <p>The class itself.</p>
  
  <pre><code>function getTimes(){ //this method just pulls the results of the query and returns them as an array
      global $connection;
      $route = $this-&gt;route;
      $station = $this-&gt;station;
      $day = $this-&gt;day;
  
      // create a prepared statement
      if ($stmt = $connection-&gt;prepare("select time from timetable where route=? and day=? and station=?")) {
          $stmt-&gt;bind_param("sss", $route, $day, $station);   // bind parameters for markers
          $stmt-&gt;execute();   //execute query             
          $stmt-&gt;bind_result($col1);  //bind result variables
          while ($stmt-&gt;fetch()){
              $results[]=$col1;
          }
      }
      $stmt-&gt;close();//close statement
      return $results;
  }
  </code></pre>