Re: Simple MySQL sample code runs out of memory
| From: | Karl DeSaulniers | Date: | Fri, 28 Oct 2011 02:19:03 +0000 |
| Subject: | Re: Simple MySQL sample code runs out of memory | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48066@lists.php.net to get a copy of this message | ||
That and maybe look into mysql_free_result() or mysql_freeresult()
Best,
Karl
Sent from losPhone
On Oct 27, 2011, at 9:08 PM, "Toby Hart Dyke" <toby@hartdyke.com> wrote:
>
>
> -----Original Message-----
> From: php@umpquanet.com [mailto:php@umpquanet.com]
> Sent: Thursday, October 27, 2011 8:00 PM
> To: php-db@lists.php.net
> Subject: [PHP-DB] Simple MySQL sample code runs out of memory
>
> Running PHP 5.3.5 on FreeBSD 8.2 connecting to a MySQL 5.1.55 server.
>
> <snip>
> $row = mysql_fetch_array( $result );
> while ($row) {
> ...
> </snip>
>
> Your while() condition will always be true, so that loop will run forever.
> Until you run out of memory.
>
> What you probably meant was to replace those two lines with something like
> this:
>
> while($row = mysql_fetch_array( $result ) ) {
>
> A new row is fetched each time the while loop goes through another
> iteration, until you run out of rows and the condition evaluates to false.
>
> Toby
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>