Php maximum executing time keeps increasing - php

I have a script in php which takes data from a database and writes it in a file. The first time I ran the script I got this:
Fatal error: Maximum execution time of 240 seconds exceeded.
So I changed this time in my php.ini to 300 and ran the script again. This time, it works. However, on running the script a second time I get this error:
Fatal error: Maximum execution time of 300 seconds exceeded.
After changing the time to 300 now, it works again but only the first time.
Any idea as to why I have to keep on increasing this max_execution_time?

At the beginning of your script you can add.
ini_set('MAX_EXECUTION_TIME', -1);
This line of code will drop the max execution time restriction of a code, allowing a php code to run forever.

Related

TCPDF Maximum execution time exceed 30 seconds

Can somebody please help me how to fix this error. I have a pdf page and I made a custom page size and made it landscape.
But when I run the page. It has an error saying "Maximum execution time exceeded 30 seconds in tcpdf.php line 18385
It only appears when I uploaded it in the server.
But when I use the program through remote it runs.
What seems to be the problem?
I had this issue as well on some content-heavy PDFs. PHP by default only allows a maximum execution time of 30 seconds.
You can increase this time in the php.ini file by changing the following line:
max_execution_time = 30
to
max_execution_time = 60
or adding this to the top of your script file.
set_time_limit(60);
60 seconds should be enough time for TCPDF to do what it needs to do but you may need to increase it further. Be careful with increasing it too much, however, as it can cause issues.
NOTE: If you're reaching the maximum execution time due to an infinite loop, this won't change anything.
you can use ini_set("you php config",0);

How to resolve 'Maximum execution time 30 seconds exceeded error', even after setting up max_execution_time=3600

Fatal error:Maximum execution time of 30 seconds exceeded in C:\inetpub\wwwroot*.php on line ##.
My php.ini already set to:
max_execution_time=3600
Error line executes a program which takes 2 minutes to execute: It looks like:
exec("C:/inetpub/wwwroot/program.cmd");
Note: It runs fine on sever, creates all output files nicely. But throws error to browser page.
(I restarted the server after changing php.ini file)
use this....
ini_set('max_execution_time', 0); // zero means takes its own time.
This will execute the php program till it is fully executed.
You can set the execution time dynamically on the same page like this-
ini_set('max_execution_time', 300);
Please add this line in your .htaccess file:
php_value max_execution_time 0

Maximum execution time of 30 seconds exceeded for file upload

I need to upload big files with a PHP script. I set max_upload_size and so on. I tried to upload a big file that took 30 minutes. Than I get:
Maximum execution time of 30 seconds exceeded ... on line 1
My first line has a constant definition so it is impossibile that the script lose all exec time in that line.
Seems that the script excecution time get the elapsed time from the beginning of upload instead of the end... Am I right? I don't want to extend the normal execution time, I just want to let php count only its time and not the upload time. Is it possibile?
crete a php.ini file write
max_execution_time = 0
save and upload your main dir

PHP max execution time wrong

One of my PHP scripts is throwing the following error at me:
Fatal error: Maximum execution time of 30 seconds exceeded
The problem is that the script has only been executing for a few seconds.
I've timed everything between 2 and 10 seconds.
set_time_limit and ini_set('max_execution_time') have no effect (because of PHP safe mode).
Now I could just increase the value in my php.ini , but I would like to know why this error is thrown within a fraction of the actual maximum execution time.
The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.
Or You can user set_time_limit(0) it will help only safemode.
This means that you might have an infinite loop somewhere or there is some code that has a timeout higher than 30 seconds.

time of 30 seconds exceeded error? file get contents

i have this error:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\AppServ\www\facebook\classes\burccek.class.php on line 56
(im using file_get_contents)
(in this program i post file_get_contents data to facebook user wall(offline_access))
It means the file_get_contents operation takes more time that the max execution time of PHP. If you need a longer time, add this line at the top of your file: set_time_limit($seconds);
However 30 seconds seems a long time already so there might be some other issue with your application.
If duration of posting file to FB is longer than 30s (default maximum execution time of php script), use
set_time_limit ( 120 );
(or more in seconds) before executing file_get_contents
When posting data to other URLs, you should rely on CURL or even in extreme case may go to socket level. Curl has better control on connection time outs to handle network latency, much more set of options. In some hosting environments or servers a sys admin may restrict what all php.ini settings you can change, though you can change set_time_limit
You can change your set_time_limit in your php.ini file to alter the maximum execution time that php can use for a script.

Categories