note 49445 deleted from control-structures.while by cece

From: Date: Fri, 28 Jan 2005 09:47:59 +0000
Subject: note 49445 deleted from control-structures.while by cece
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-84117@lists.php.net to get a copy of this message
Note Submitter: caesardemon[at]gmail.com Reason: bad code ---- For other PHP newbies, such as myself who are new to integrating it in with MySQL, I had a problem, where if I did <? while($arr = mysql_fetch_array(mysql_query("SELECT something,something_else,another_thing FROM some_db"))) { // do something useless } ?> it would be an infinite loop, it took me a while to discover the solution, but I found it. To work around this problem, simply use the following instead: <? $query = mysql_query("SELECT something,something_else,another_thing FROM some_db"); while($arr = mysql_fetch_array($query)) { // do something useless } ?> I'm not sure of the cause of this, but it's an easy work around to whatever it may be. Hope this helps some of the other newbies out there. :)

« previous php.notes (#84117) next »