Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in

Posted by user1493540 on Stack Overflow See other posts from Stack Overflow or by user1493540
Published on 2012-06-30T20:55:19Z Indexed on 2012/06/30 21:16 UTC
Read the original article Hit count: 179

Filed under:
<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.

© Stack Overflow or respective owner

Related posts about php