output all data from db to a php page
- by Sarit
Hi, I'm a real beginner with PHP & mysql.
Just for studying and for a simple example at school I would like to work this simple query and possibly output all the rows (or maybe even one) to a very basic output on a php page:
<?php
$user= "root";
$host="localhost";
$password="";
$database = "PetCatalog";
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn’t connect to server");
$query = "SELECT * FROM Pet";
$result = mysql_query($cxn,$query) or die ("Couldn’t execute query.");
$row = mysqli_fetch_assoc($result);
echo "$result";
?>
this is the error message i've been getting:
Warning: mysql_query() expects parameter 1 to be string, object given in C:\xampplite\htdocs\myblog\query.php on line 18
Couldn’t execute query.
What should I do?
Thanks!