title: MYSQLi_Query not working with DB Connection in Includes Folder
body: <p>I've setup a dbconn.php file in the includes folder outside of the document root.  When I reference $mysqli from it as part of the select statement, I receive an error </p>
  
  <pre><code>Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli     
  in /home/tgitcorp/public_html/Admin/admin_index.php on line 18
  Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given 
  in /home/tgitcorp/public_html/Admin/admin_index.php on line 20 
  </code></pre>
  
  <p>My dbconn.php is as follows:</p>
  
  <pre><code>&lt;?php
      $mysqli = new mysqli('localhost','dbuser','pass','dbname');
      if ($mysqli-&gt;connect_error){
          die('Connect Error (' . $mysqli_connect_errno . ')'. $mysqli-&gt;connect_error);
      }
      $mysqli-&gt;close();   
  ?&gt;
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php 
  include_once '/home/tgitcorp/includes/dbconn.php';
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML     
  1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
      &lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type" /&gt;
      &lt;title&gt;Tricorp Job Listing Admin Panel&lt;/title&gt;
      &lt;link rel="stylesheet" href="../css/style.css" type="text/css"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Job Listing Administration&lt;/h1&gt;
      &lt;h2&gt;Step 1:  Please Select Your Restaurant&lt;/h2&gt;
      &lt;form id="frmSelStore" method="post"&gt;
      &lt;?php 
      $result=mysqli_query($mysqli,'SELECT location from restaurant');
      echo '&lt;select name="ddlStore"&gt;';
      while($row=mysqli_fetch_array($result))
      {
          echo '&lt;option value="' . htmlspecialchars($row['location']) . '"&gt;&lt;/option&gt;';
      }
      echo '&lt;/select&gt;';
      ?&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to query the restaurant table to retrieve the location field and populate that field as values in my dropdown box.  Can anyone assist in resolving this error?</p>
  
  <p>Thanks!</p>
  
  <p>UPDATE #2:  Revised code block:</p>
  
  <pre><code>&lt;?php 
  $result=$mysqli-&gt;query($mysqli,'SELECT location from restaurant');
  echo '&lt;select name="ddlStore"&gt;';
  while($row=$mysqli-&gt;query($result))
  {
      echo '&lt;option value="' . htmlspecialchars($row['location']) . '"&gt;';
      '&lt;/option&gt;';
  }
  echo '&lt;/select&gt;';
  ?&gt;
  </code></pre>
  
  <p>yields the error message:</p>
  
  <pre><code>Warning: mysqli::query() expects parameter 1 to be string, object given 
  in /home/tgitcorp/public_html/Admin/admin_index.php on line 18
  Warning: mysqli::query() [mysqli.query]: Empty query 
  in /home/tgitcorp/public_html/Admin/admin_index.php on line 20 
  </code></pre>