tags:

views:

297

answers:

2

Hello all,

I make 7 get requests at the same time to one PHP script - two of the requests are successful and the other requests I get an output of Max Execution of 60 seconds exceeded!

The thing is I have put this at the top of my script:

set_time_limit(300000);

I have also set this in my PHP.ini file and have restarted apache several times.

max_execution_time = 300000

Why does it keep giving me this error?!?

Thanks all

Update

I have just looked at firebug and it looks as if all requests are not fully fired i.e. it shows the request is still trying to be made. In this case, is it possible for PHP to throw that error if a request has been made to it but it has not started execution!?

It gives me that error on line 1 - so it didn't even run any part of this script - is this what it means?

Update 2

Just showing the full error:

[Mon Nov 23 13:05:37 2009] [error] [client 127.0.0.1] PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\webs\process_txt.php on line 1, referer: http://localhost/webs/front-end/path.php

Why does it say line 1?

+1  A: 

Check that ini_get reports the correct "max_execution_time". Also make sure that it reports for "safe_mode" 0 (though this is deprecated and set for removal in PHP 6) as the PHP docs state:

This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini.

Also note in the documentation:

Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details.

Narrow down your problem. Ignore Ajax for the time being and perform a normal HTTP request on the page in question. Test the timeout to make sure the execution time is actually reached:

for ($i=1; $i<=300; $i++) {
    echo "<p>$i seconds</p>";
    flush();
    ob_flush();
    sleep(1);
}
Paul Lammertsma
I did a check for the max_execution_time and returned 3000. I have also had a look in my ini file and safe_mode is already set to Off.
Abs
Note that you might have to change the Apache or IIS timeout as well.
Paul Lammertsma
Just had a look at my Apache 2.2.1.1 httpd.conf and there is nothing on there to do with timeout etc - should I be looking elsewhere?
Abs
You should have more than one .conf file with Apache 2.2 I think?
Pekka
By default, Apache waits 300 seconds for events to complete a request. See the documentation: http://httpd.apache.org/docs/2.0/mod/core.html#timeout
Paul Lammertsma
You might also want to try the example code above.
Paul Lammertsma
Yep, just found this and increased it to 300000 (!) - but this didn't help me either. If this were a problem though, would PHP report this?
Abs
If PHP exceeded the max_execution_time, it would result in a fatal error informing you that the maximum execution time was reached. If the example code executes neatly, spitting out "1 seconds", "2 seconds", etc. for several minutes, there is nothing wrong with your configuration. Which error are you receiving?
Paul Lammertsma
Also, are you seeing any fatal errors in Apache's error log?
Paul Lammertsma
Yes, it does show the PHP Fatal error.
Abs
A: 

Also, make sure you are using the right php.ini file. Using the wrong one happens very often. Call phpinfo() an check the php.ini path it outputs.

Pekka
I made sure of this too - viewing phpinfo shows the settings that I expect.
Abs