title: Fatal error: Call to a member function fetch_array() on a non-object
body: <p>How do I change this code so I don't receive the above error?</p>
  
  <p>Here is the full error:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function fetch_array() on a non-object in /home/bestc165/public_html/opinuo.com/stream.php on line 10</p>
  </blockquote>
  
  <pre><code>&lt;?php 
  $link = mysqli_connect('localhost', 'bestc165_opinuo', 'opinuo');
  
  $sql_string = 'SELECT * FROM debates LIMIT 2  order by ts ';
  
  $result = mysqli_query($link,$sql_string );
  
  while($row = $result-&gt;fetch_array())
  {
      $rows[] = $row;
  }
  
  foreach($rows as $row)
  {
      $name =  $row['name'];
      $text =  $row['text'];
  ?&gt;
  
  &lt;h2&gt;&lt;?php echo $name;?&gt;&lt;/h2&gt;
  &lt;p&gt;&lt;?php echo $text;?&gt;&lt;/p&gt;
  
  &lt;?php
  
  }
  
  ?&gt;
  </code></pre>