Re: Gathering data from a database

From: Date: Sun, 23 Mar 2003 05:47:01 +0000
Subject: Re: Gathering data from a database
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-26567@lists.php.net to get a copy of this message
Hi, $select = "mysql_select_db ($database)"; << like Mike said you don't need to have this in " and no need for a var to be assigned... Then when you want to print out the data print_r( $row ); you can use $row['table_row_name']; :) Adam At 08:26 PM 3/22/2003 -0500, you wrote:
I have been having this problem for a while now, and I cant figure it out. the code is: <? $host = "localhost"; $uname = "sniper"; $pass = "starcraft"; $database = "sha"; $tablename = "members"; $connect = mysql_connect ($host, $uname, $pass); $select = "mysql_select_db ($database)"; $query = "SELECT * from $tablename"; $result = mysql_query ($query, $connect); while ($row = mysql_fetch_array($result)) { print_r( $row ); echo mysql_error(); } ?> mysql has an error on line 19. Line 19 is while ($row = mysql_fetch_array($result)). What am I doing wrong? Thanks for your help, Mike


« previous php.db (#26567) next »