output all data from db to a php page
Posted
by Sarit
on Stack Overflow
See other posts from Stack Overflow
or by Sarit
Published on 2010-05-16T18:14:22Z
Indexed on
2010/05/16
18:20 UTC
Read the original article
Hit count: 207
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!
© Stack Overflow or respective owner