-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ooops, incorrect scripts. Let's try again:

     --script1.php--    
     // for loop as in Zachery's example
     <?php
         $res = array();
         for( $i=0; $i<=count($res); $i++ ) {
             $res[$i] = $i;
             echo $i, "\n";
         }        
     ?>
 
     --script2.php--
     // modified for loop
     <?php
         $res = array();
         for( $i=0; $i<count($res); $i++ ) {
             $res[$i] = $i;
             echo $i, "\n";
         }        
     ?>

That's much better. ;-)

Peter Brett

- -----------
peter:AT:peter-b:DOT:co:DOT:uk
www.peter-b.co.uk

- ----- Original Message ----- 
From: "Peter TB Brett" <[EMAIL PROTECTED]>
To: "Zachery Hostens" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Friday, May 31, 2002 9:26 PM
Subject: Re: [PEAR] [HTML_Form] cant change values in array after
getAll()


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> In the for loop initialisation try changing:
> 
>     $i <= count($res)
> 
> to:
> 
>     $i < count($res)
> 
> Reason: The usual thing that causes that sort of error is an
> incorrect iteration condition that causes the loop to run forever
> and so make an infinitely large array. I ran the below scripts
> (using
> php-cli) to see what was going on:
> 
>     --script1.php--    
>     // for loop as in Zachery's example
>     <?php
>         $res = array();
>         for( $i=0; $i<=count($res); $i++ ) {
>             echo $i, "\n";
>         }        
>     ?>
> 
>     --script2.php--
>     // modified for loop
>     <?php
>         $res = array();
>         for( $i=0; $i<count($res); $i++ ) {
>             echo $i, "\n";
>         }        
>     ?>
> 
> Since the $res array is zero length, if the for loop is correctly
> formed the script should output a blank page (no array members,
> therefore no iterations).  However, script1.php output a list of
> numbers from 0 to when I terminated script execution by pressing
> Ctrl-C.
> 
> Try checking your iteration conditions and try again. ;-)  Sorry if
> I'm barking up the wrong tree...
> 
> Peter Brett
> 
> - -----------
> peter:AT:peter-b:DOT:co:DOT:uk
> www.peter-b.co.uk
> 
> - ----- Original Message ----- 
> From: "Zachery Hostens" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, May 30, 2002 6:16 PM
> Subject: [PEAR] [HTML_Form] cant change values in array after
> getAll()
> 
> 
> > im using PHP 4.1.2 and the stock PEAR with MySQL
> > 
> > i get the array using DB::getAll() fine
> > 
> > but when i try to go
> > 
> > 18   for( $i=0; $i<=count($res); $i++ ) {
> > 19       $res[$i]['stamp'] = date( 'l, F dS @ h:i A',
> > $res[$i]['stamp'] ); 20   }
> > 
> > i get this error ::
> > 
> > Fatal error: Allowed memory size of 8388608 bytes exhausted
> > (tried to allocate 40 bytes) in /home/zacheryh/htdocs/news.php on
> > line 19   
> > 
> > Fatal error: Allowed memory size of 8388608 bytes exhausted
> > (tried to allocate 40 bytes) in Unknown on line 0  
> > 
> > 
> > i have checked that the var is there in the array and it is a
> > correct unix epoch.  if i change the for() loop to this it works
> > perfectly fine ::  
> > 
> > 18   for( $i=0; $i<=count($res); $i++ ) {
> > 19       echo date( 'l, F dS @ h:i A', $res[$i]['stamp'] );
> > 20   }
> > 
> > it will then work perfectly fine...
> > 
> > i was wondering what maybe causing this and how i can go about
> > fixing ???  
> > 
> > thanks in advance.
> > ~ Zachery
> > 
> > -- 
> > PEAR General Mailing List (http://pear.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -----BEGIN PGP SIGNATURE-----
> Version: PGPfreeware 7.0.3 for non-commercial use
> <http://www.pgp.com>  
> 
> iQA/AwUBPPfciBmmzLp5+kKBEQJCWwCgz1fBbbxtOS/26cm4p5pIGYJhdykAoMhB
> 2UmFRDznRE/YOiBeRGOhqQnu
> =QY+n
> -----END PGP SIGNATURE-----
> 

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPPfdpRmmzLp5+kKBEQIPrQCeIiK+n2ZpukVHVuOx/0RgsPi9jmQAniW/
qVDQBXlXNCiuM7ryRrTTbPxj
=7Cck
-----END PGP SIGNATURE-----



STANDARD DISCLAIMER


E-mail communication is not secure and can easily be forged or tampered with during 
transmission.  This message appears to originate from The Oratory School Association, 
but does not necessarily represent the opinions of the Association, its employees or 
students.  Should you have any concerns regarding the content of this message then 
please contact [EMAIL PROTECTED]

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

Reply via email to