title: "Fatal error: Call to a member function fetch_array() on a non-object in"
body: <p>The following code is getting the error message displayed in the title:</p>
  
  <pre><code>while($row = $result-&gt;fetch_array(MYSQLI_ASSOC)) {
  $rep_id       = $row['Report_ID'];
  $rep_title    = $row['Report_Title'];
  $rep_keywords = $row['Report_Keywords'];
  $rep_cat      = $row['Report_Category_Subs'];
  $rep_status   = $row['Report_Private'];
  </code></pre>
  
  <p>Any Ideas why this may be the case?</p>
  
  <p>Thanks</p>
  
  <p>Edit: Here is the code below the while </p>
  
  <pre><code>if ($name == $_SESSION['user']['User_ID'] || isAdmin()) {
  // User is retrieving their own data or admin is retrieving data
  global $conn;
  
  $name = $conn-&gt;real_escape_string($name);
  $sql = 
  "SELECT * 
  FROM reports 
  WHERE User_ID = '".$name."'
  ORDER BY Report_ID DESC
  LIMIT 500;";
  
  $result = $conn-&gt;query($sql);
  
  $tbl  = '&lt;form action="myreports.php" method="post" id="modify"&gt;
  &lt;select name="choice"&gt;
  &lt;option value=""&gt;--Select Bulk Option--&lt;/option&gt;
  &lt;option value="reverse-status"&gt;Change Public Status&lt;/option&gt;
  &lt;option value="change-cats"&gt;Change Categories/Keywords&lt;/option&gt;
  &lt;option value="delete"&gt;Delete Reports&lt;/option&gt;
  &lt;/select&gt;
  &lt;input class="formbutton" id="sub" type="submit" name="submit" value="Submit" /&gt;&lt;br/&gt;
  
  &lt;table class="table"&gt;';
  $tbl .= '&lt;tr&gt;  &lt;th class="no-bg"&gt;&lt;input type="checkbox" id="selectall" class="left" /&gt;                                                                        
  &lt;/th&gt;  &lt;th&gt;ID&lt;/th&gt;  &lt;th&gt;Title&lt;/th&gt;  &lt;th&gt;Keywords&lt;/th&gt;  &lt;th&gt;Category&lt;/th&gt;    
  &lt;th&gt;Public&lt;/th&gt;&lt;/tr&gt;';
  </code></pre>