note 57731 added to control-structures.while
| From: | brownergATgmailDOTcom at osu1 dot php dot net | Date: | Wed, 12 Oct 2005 15:38:28 +0000 |
| Subject: | note 57731 added to control-structures.while | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96901@lists.php.net to get a copy of this message | ||
The while loop below recurses infinitely and simply returns the first result each time:
$sqlResult = mysql_query("select column1 from user")
$arrayHandle = mysql_fetch_array($mysqlResult, MYSQL_NUM);
while ($record=$arrayHandle) {
print $record[0]."\n";
}
The funny thing is if you pass the Handle straight to the while condition, it works properly!
$sqlResult = mysql_query("select column1 from user")
while ($record=mysql_fetch_array($mysqlResult, MYSQL_NUM)) {
print $record[0]."\n";
}
weird! (using php 4.4.3)
----
Manual Page -- http://www.php.net/manual/en/control-structures.while.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57731
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57731&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57731&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57731&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57731&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57731&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57731&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57731&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57731&report=yes
Search -- http://master.php.net/manage/user-notes.php