Re: Simple MySQL sample code runs out of memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx> wrote:

> 
> 
> -----Original Message-----
> From: php@xxxxxxxxxxxxx [mailto:php@xxxxxxxxxxxxx] 
> Sent: Thursday, October 27, 2011 8:00 PM
> To: php-db@xxxxxxxxxxxxx
> Subject:  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
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux