Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
- by user1493540
<html>
<title>Title</title>
<body>
<link type="text/css" rel="stylesheet" href="css/bootstrap.css"/>
</body>
<center>
<?
mysql_connect ("localhost", "root","") or die (mysql_error());
mysql_select_db ("dbname");
$term = $_POST['term'];
$sql = mysql_query("select * from items where name like '%$term%'");
while ($row = mysql_fetch_array($sql)){
echo '<table class="table - striped"> <theader> <tr> <th>ID</th> <th></br> Name</th></tr>'; echo ' <tbody><td>'.$row['id']; echo'</td>';
echo '<td>'; echo '</theader>' .$row['name']; echo '</td>';
echo '';
}
?>
</center>
<script src="js/bootsrap.js"> </script>
</html>
I'm, getting this error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/runedev1/public_html/itemdb/search.php on line 19
When I run the code on localhost using Xampp, it works fine, when I upload it to the web-host, the error appears.
Yes, I am changing the database name, user and password when putting it on the webhost.