Jump to content


Photo

Counting all the values in an array


  • Please log in to reply
3 replies to this topic

#1 stewarty77

stewarty77
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 19 March 2006 - 05:34 PM

Hi

I have an array $byteslist which contains a list of integers gathered from a MySQL database.

I am using the following code:

$totalbytes = array_sum($byteslist);

But I get the following error:

Fatal error: Maximum execution time of 30 seconds exceeded

Where am I going wrong?


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 19 March 2006 - 05:45 PM

Please post your code.

How large is the array?

Display the array first
<?php echo '<pre>' . print_r($byteslist,true).'</pre>'; ?>

Ken

#3 earl_dc10

earl_dc10
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 19 March 2006 - 07:27 PM

check any nearby loops (ie, perhaps a loop to fill the array) I normally time out on neverending loops if I forget something, but the actual line that it displays as timing out is sometimes only related to the loop, not actually in it
got a problem? Google helps many of those in need

#4 stewarty77

stewarty77
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 20 March 2006 - 09:15 AM

[!--quoteo(post=356457:date=Mar 19 2006, 07:27 PM:name=earl_dc10)--][div class=\'quotetop\']QUOTE(earl_dc10 @ Mar 19 2006, 07:27 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
check any nearby loops (ie, perhaps a loop to fill the array) I normally time out on neverending loops if I forget something, but the actual line that it displays as timing out is sometimes only related to the loop, not actually in it
[/quote]


Thanks, you were right, I had that line of code within a while loop, once I took it out it worked fine.

Your help was much appreciated!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users