How do I change this code so I don't receive the above error?
Here is the full error:
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
<?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->fetch_array())
{
$rows[] = $row;
}
foreach($rows as $row)
{
$name = $row['name'];
$text = $row['text'];
?>
<h2><?php echo $name;?></h2>
<p><?php echo $text;?></p>
<?php
}
?>
fetch_array()withfetch(PDO::FETCH_ASSOC)- Tirth Patelmysqli_connectfunction - Tirth Patel