time of 30 seconds exceeded error? file get contents - php

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.

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);

PHP Fatal error: Max execution time exceeded - EVEN after set_time_limit(0)

I keep running into the following PHP error when running my script
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\apps\sqlbuddy1.3.3\functions.php on line 22
I already put this in my PHP file, and I STILL get this error message.
#set_time_limit(0);
Am I missing something?
Edit: This error only shows up after SEVERAL minutes, not after 30 seconds. Could something also be delaying its appearance?
set_time_limit() has no effect when running in safe_mode:
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.
You can check the value of safe_mode and max_execution_time with phpinfo().
Given the facts that you are using Windows and experiencing the timeout later than 30s you might have somewhere else in your code a reset of the timeout (set_time_limit(30)):
The set_time_limit() function [..] 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. This is not true on Windows where the measured time is real.
Search your code for:
ini_set('max_execution_time', 30)
set_time_limit(30)
Rather than relying on the PHP file to change the php.ini settings, you should do it yourself. Find where the php.ini is kept for WAMP, and change/add this line:
max_execution_time = 500;
There is a PHP config that unallows the script to change the time_limit.
You can change your PHP behavior on php.ini file

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.

PHP script timeout in Log Analyzer

I have been trying to get Log Analyzer to work for longer than I care to admit. I can't seem to get syslog messages to display in the Log Analyzer web-GUI, but this morning I got the following error:
"While reading the logstream, the php script timeout forced me to abort at this point. If you want to avoid this, please increase the LogAnalyzer script timeout in your config.php. If the user system is installed, you can do that in Admin Center."
I was not getting this error on Friday; only "No syslog records found." The timeout is set to 30 seconds in the config file, but I read that setting will get overwritten back to the default anyway. The database grew to over 4GB over the weekend. Does the the db size have anything to do with this?
It's pretty clear I am new to php and Log Analyzer, so any help with both would be greatly appreciated. I can post config file settings if needed.
Try to increase time. 30 second may be not enough for parse large file. For example set 600 seconds.
Another case to increase timeout - edit following line in php.ini file
; Duration of time, in seconds for which to cache realpath information for a given
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
max_execution_time = 30;
Too many records in the database, the script does not have enough time to process everything. I keep the last 14 days in the database, that's enough.
USE Syslog;
DELETE FROM Syslog.SystemEvents WHERE ReceivedAt < DATE_SUB(NOW(), INTERVAL 14 DAY);

Fatal error: Maximum execution time of 400 seconds exceeded

I have a PHP script that fails when executing a long mysq_query. The error message is:
Fatal error: Maximum execution time of 400 seconds exceeded in....
I use XAMPP for windows and I have changed the php.ini file (there is only one in my installation), setting max_execution_time to a large value that is not 400 seconds. Nevertheless I keep getting the error message above....
Any idea of how to solve this?
Thanks
Beto
As Ignacio says, something may be overriding the php.ini setting. You can definitively set the timeout for that script using set_time_limit
set_time_limit(600);
You can also set it to 0, which removes any time restriction - although this is not best practice.
400 seconds is a huge amount of time for a query - have you looked into adding indexes on commonly used columns in your db?
You need to restart your web server for PHP to re-parse your config file.
Something in either a .htaccess file or within a PHP script is probably resetting it back to 400 seconds.
Having said that, 400 seconds is still an excessive amount of time for a query. You should consider farming the task off to another process if it really needs to take that long.

Categories