Jump to content

Archived

This topic is now archived and is closed to further replies.

spelltwister

Timeing out

Recommended Posts

Hello,

First off, I was wondering if this is a PHP error or a server error and if it is, how do i make the time increase:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/online/public_html/...

Second, because the script is timing out, i was wondering if someone could help me with an array question.

I have an array: $offense_infantry = array( "number" => array(), "nation" => array() );

What happens is a bunch of infantry pieces go into this array and they can have different numbers to represent how many are there. During combat, I do this:

$upper = sizeof($offense_infantry["nation"]);
$index = rand(0,$upper-1);
if($offense_infantry["number"][$index] > 0){
$attInfantry--;
$offense_infantry["number"][$index] -= 1;
$k+=1;
}
if($offense_infantry["number"][$index] ==0){
unset($offense_infantry["number"][$index]);
unset($offense_infantry["nation"][$index]);
}

Ok, now that it's unset, I don't want to be able to hit that unit again, i want it out of the array and all the rest smushed together. Is this right? Also, after each combat, i want to unset all my arrays, can i just do this:
unset($offense_infantry); ?

Thanks.

Mike

Share this post


Link to post
Share on other sites
[!--quoteo(post=353089:date=Mar 9 2006, 12:16 AM:name=spelltwister)--][div class=\'quotetop\']QUOTE(spelltwister @ Mar 9 2006, 12:16 AM) [snapback]353089[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hello,

First off, I was wondering if this is a PHP error or a server error and if it is, how do i make the time increase:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/online/public_html/...

Second, because the script is timing out, i was wondering if someone could help me with an array question.

I have an array: $offense_infantry = array( "number" => array(), "nation" => array() );

What happens is a bunch of infantry pieces go into this array and they can have different numbers to represent how many are there. During combat, I do this:

$upper = sizeof($offense_infantry["nation"]);
$index = rand(0,$upper-1);
if($offense_infantry["number"][$index] > 0){
$attInfantry--;
$offense_infantry["number"][$index] -= 1;
$k+=1;
}
if($offense_infantry["number"][$index] ==0){
unset($offense_infantry["number"][$index]);
unset($offense_infantry["nation"][$index]);
}

Ok, now that it's unset, I don't want to be able to hit that unit again, i want it out of the array and all the rest smushed together. Is this right? Also, after each combat, i want to unset all my arrays, can i just do this:
unset($offense_infantry); ?

Thanks.

Mike
[/quote]

the error message your getting something that is set in the PHP.ini file, which looks like it's set to 30 seconds, so a php script cannot take more than 30 seconds to complete.

Share this post


Link to post
Share on other sites
Thanks, I fixed that problem, but can anyone tell me how to remove an element from an array and shift everything else down so that it cannot be selected again and the size go down 1 as well? Thanks

Share this post


Link to post
Share on other sites
This is same question I have answered in your other post. Don't double post. READ FORUM GUIDELINES.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.