Re: Random select -- Where am I going wrong?

From: Date: Mon, 05 Jul 2004 07:46:06 +0000
Subject: Re: Random select -- Where am I going wrong?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-35126@lists.php.net to get a copy of this message
See Below On Sun, 2004-07-04 at 05:54, Ronald "The Newbie" Allen wrote: > Here is my code.... I keep on getting a Resource id #2 ......whatever that > means....any help would be appreciated! > > <html> > > <head> > > <title>Top Frame</title> > > </head> > > <body bgcolor="#ffffff" text="#000000" link="#0000ff" > vlink="#800080" > alink="#ff0000"> > <EMBED SRC="" autostart="true" hidden="true" > loop="true" volume="100%"> > <? > > $db_host = '######; > $db_user = '######'; > $db_pass = '######'; > $db_name = '######'; > > $conn = mysql_connect($db_host,$db_user,$db_pass); > > if ($conn == true) { > > > // Select the database. > mysql_select_db($db_name,$conn); > > > $db_table = 'music'; > $music = mysql_query ("Select * from $db_table ORDER BY RAND() Limit 1"); > > if(!$music) die("Query Failed."); > > while($row = mysql_fetch_row($music)) > > print "$music"; you need something like print $row however, that still will not work. print_r( $row ) will give you all the values. print( $row->the_table_name would yield each value. NOTE: the syntax above is for a call to $row = mysql_fetch_object( $music ) lookup the correct syntax for mysql_fetch_row( $table ). You might want to check mysql_fetch_assoc and mysql_fetch_array to have even more fun! If you really wish to know more check out mysql_result( ) quite useful when you only seek a couple values from the resultset. hope that helps Alvaro Zuniga (337) 654 6515 www.zunitek.com Zunitek Solutions > } > ?> > > > </body> > > </html>

« previous php.db (#35126) next »