0

Is there any reason for a PHP script to return a fatal error of:

Fatal error: Maximum execution time of 60 seconds exceeded in 
H:\xampplite\htdocs\mlm\tera.php on line 1

When my PHP ini is set to "300000" and further more I set set_time_limit(300000); in the script itself. Safemode is off. In addition, Apache's timeout has also been set to "300000".

Why would be PHP return this - I am happy to hear any case why this would happen!!

I am using this PHP script mainly to run queries via SQLCMD using the exec function. I get this error after the PHP script has been executing (supposedly) for well over 5 minutes.

Note: When answering this question please assume there is no doubt that I am using the right PHP.ini file etc and what I am claiming is what is actually happening.

Thanks all for any help

P.S. I have asked this question before but thought the other question was getting messy. I have made this more specific in the hope that I can finally close the book on this. Also this a test that I have done and I am not using AJAX any more.

Update

Line 1 of Script in question:

session_start(); 
ini_set("max_execution_time" , 300000); 
error_reporting(0);
ini_set('display_errors', '0');

(I have added a line break to make it easier to read)

5 Answers 5

4

I found this comment on php.net. Is your script waiting for input from somewhere else (like a file upload) that might be exceeding 60 seconds? 60 is the default time for max_input_time, which sets how long PHP will wait to receive file data.

Sign up to request clarification or add additional context in comments.

4 Comments

Good observation - but would it return a max_execution warning or a max_input warning?
Does passing a variable via AJAX seen as an input?
Read the comment and another forum and it would return max_execution error! Strange! Let me set this and test it.
Yep, Solved my issue. I needed to extend the max_input time too! Thank you very much keithjgrant. :)
2

Is the phpinfo output actually showing the value you entered (300000) as the max_execution_time in the appropriate column? There is no differing local setting? There is no "60 seconds" anywhere in the whole phpinfo output, right?

I have to ask because the same thing has happened to myself more than once.

Then, could it be that what we are seeing is the command line output from a different script that you are executing from your main script? Or some other way that a PHP script from a different context is actually outputting this?

Comments

1

run a page with a simple php_info(); call as the only line. that will tell you what variable is really set for max execution time.

4 Comments

I have been asked this before and I have already confirmed this - hence why I have stated in my question to take everything I have said in my question as absolute fact, beyond all reasonable doubt. I have made it bold now.
Just to add - I have been struggling with this for a 2 days so I am pretty sure of my facts. ;)
well then post the results of the php_info dump so we can see the value PHP is assigning to it...
I don't know what you mean by "snarky" but my intention is to let you know that I am positive that my settings are as I have set them.
1

The execution time limit applies to php execution time, and doesn't include waiting for external programs or databases. That would explain why you're hitting the 60 second limit after over 5 minutes.

As for why you're still getting the 60 second limit, I don't know. It sounds like you're sure you are using the correct php.ini file, i'd check any .htaccess files for php directives and check the setting with phpinfo() . Change a value in the config and verify it changed in phpinfo().

Also restart your webserver.

1 Comment

The thing is I have set it "300000" - if it returned a fatal error of "300000" seconds has been exceeded then I would be really happy as I can see PHP is working in the way it is supposed to.
0

Have you tried setting max_execution_time to something a little lower like 300? Or do you really need three and a half days of execution time? (hint: if the answer is yes, PHP is probably not the tool for the job) Some quick googling didn't return any results, but I wouldn't be surprised if 300,000 exceeded some hard-coded limit in PHP or apache. I've run it as high as 500 without problems, but never more than that.

2 Comments

You can set an indefinite timeout by specifying 0.
I've run many a script for months at a time, using set_time_limit(0). PHP's certainly not ideal for those sorts of jobs, but sometimes it's convenient (since you can reuse your application's objects, libraries, etc.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.