This question already has an answer here:
I created a very simple database on mySQL using phpMyAdmin. Now I want to connect my database through php file so that I can manipulate data in DB, i.e. inserting, deleting, showing, updating data. I wrote the code:
index.php file:
<?php
include 'includes/connection.php';
$query="SELECT * FROM people";
$result=mysql_query($query);
while($person= mysql_fetch_array($result)){
echo "<h3>". $person['name']."</h3>";
}
?>
connection.php file:
<?php
$dbhost='localhost';
$dbuser='root';
$dbpass='';
$db='mysql_tut';
$conn=mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);
?>
But it shows the following error in the browser window:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\phpMyAdmin\index.php on line 5
</div>