Re: Why while doesn't work?

From: Date: Thu, 24 Jan 2002 14:25:20 +0000
Subject: Re: Why while doesn't work?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-81880@lists.php.net to get a copy of this message
Anthony, > Although the table con_inf in db sbwresearch contains 3 records with > username as the first column, the following short script generates a blank > page: > > <?php > $connection=mysql_connect("localhost","wagner","xyz") or die > ("No > connection!"); > $db=mysql_select_db("sbwresearch",$connection) or die ("No database!"); > $qry_1="select * from con_inf"; > $result_1=mysql_query($qry_1,$connection) or die ("No query # 1!"); > while ($row_1=mysql_fetch_array($result_1,"mysql_assoc")) > { > $username=$row_1["username"]; > echo "$username"; > }; > mysql_free_result($result_1); > mysql_close($connection); > exit; > ?> > > Why? I've use the statement in other scripts and it works! Please review http://www.php.net/manual/en/function.mysql-fetch-array.php. The second argument to mysql_fetch_array is the name of a system-defined constant, not a string (http://www.php.net/manual/en/language.constants.php). Given the way you have coded this example, may I also suggest mysql_assoc() at http://www.php.net/manual/en/function.mysql-fetch-assoc.php Regards, =dn

« previous php.general (#81880) next »