Re: can connect but error in retrieving data from mysql database

From: Date: Thu, 25 Jan 2001 03:52:03 +0000
Subject: Re: can connect but error in retrieving data from mysql database
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6155@lists.php.net to get a copy of this message
Scott, You probably need to add something like: while ($row = mysql_fetch_row($result)) { print ("$row[0], $row[1]<br>\n"); } which will print out the first two columns from the query. Wayne On Thu, 25 Jan 2001 14:02, Scott wrote: > Hi, > > I have mysql, apache and php on my redhat 7 box and when I try to retrieve > some data from the database and display it on a webage, it doesn't display > anything. I seem to be able to connect to it fine but not pull any data. > Here is the main part of the code I am using: > > <html> > <head> > <title> #### This is a PHP test #### </title> > </head> > <body bgcolor="blue"> > > <?php > //db_connect.php > > include "common_db.inc"; > error_reporting(1); > > $link_id = db_connect("phptest"); > if (!$link_id) { > die (sql_error()); > } > > else echo "Successfully made a connection to $dbhost using $default_dbname > . <br>"; > > if (!$result=mysql_query("select * from user",$link_id)) { > echo "No! I selected nada from the user table"; > } > else echo "Yes I can connect! Amen!"; > ?> > > </body> > </html> > > Basically what happens is I get the message saying that I successfully > connected to the database and then underneath I get the "No! I selected > nada..." message. Could someone point me in the right direction? > > Thanks, > > Scott

« previous php.db (#6155) next »