Maximum execution time of 300 seconds in Xampp on Windows - php

I have changed php.ini settings and max timeout in http-default.conf under apache but still I get the following error:
Maximum execution timeout of 300 seconds
I have even added set_time_limit and ini_set to the php script but still I get this error.
How do I resolve this?
Note:
I tried the options in Fatal error: Maximum execution time of 300 seconds exceeded.

Change Maximum Execution Time
php.ini
max_execution_time = 30
From Code
Start your code with,
ini_set('MAX_EXECUTION_TIME', 3600);
.htaccess
php_value max_execution_time 3600
No matter which option you choose, restart Apache service.

use below thing and i think will work
set_time_limit(0);

Conditions:
If you are using phpMyadmin to import large sql files and you have increased max_execution time, max file upload limit and everything needed
And If none of the above answers work for you come here
Go to your server (xampp or wamp) folder, in my case here is the relative path to the file that I need to modify: C:\xampp\phpMyAdmin\libraries\config.default.php
/**
* maximum execution time in seconds (0 for no limit)
*
* #global integer $cfg['ExecTimeLimit']
* by defautlt 300 is the value
* change it to 0 for unlimited
* time is seconds
* Line 709 for me
*/
$cfg['ExecTimeLimit'] = 0;

In php.ini you must check mysql.connect_timeout either.
So, for example, change it to:
mysql.connect_timeout = 1000
That time will be always counted in seconds

Related

codeigniter -- helper and nice_date [duplicate]

I keep getting this PHP error:
Fatal error: Maximum execution time of 300 seconds exceeded
I have tried setting my max_execution_time and my max_input_time settings in php.ini (both apache and cli) to 0, -1 and 4000 seconds each.
And i still get the error saying:
Fatal error: Maximum execution time of 300 seconds exceeded
As well my script runs over 300 seconds before i get this message
I am running the script through command line.
I also checked my phpinfo() so see which php.ini I am using.
Even more interesting I have tried setting max_execution_time and max_input_time settings to 5 second and my script will run way beyond 5 seconds before I get the:
Fatal error: Maximum execution time of 300 seconds exceeded
If you are using WAMP Go to :
Increase the max_execution_time in php.ini then go to
C:\wamp\apps\phpmyadmin3.4.10.1\libraries (change path according to your installation)
open config.default.php and change value for $cfg['ExecTimeLimit'] to 0:
$cfg['ExecTimeLimit'] = 0;
This will resolve the issue for PhpMyAdmin imports.
Xampp Users
Go to xampp\phpMyAdmin\
Open config.inc.php
Search for $cfg['ExecTimeLimit'] = 300;
Set a larger value or change to 0 for unlimited
If not found add $cfg['ExecTimeLimit'] = 900; (or 0 for unlimited)
Save the file and restart the server
Important: setting the execution time limit to unlimited is not recommended.
At the beginning of your script you can add.
ini_set('MAX_EXECUTION_TIME', '-1');
I encountered a similar situation, and it turns out that Codeigniter (the PHP framework I was using) actually sets its own time limit:
In system/core/Codeigniter.php, line 106 in version 2.1.3 the following appears:
if (function_exists("set_time_limit") == TRUE AND #ini_get("safe_mode") == 0)
{
#set_time_limit(300);
}
As there was no other way to avoid changing the core file, I removed it so as to allow configuration through php.ini, as well as give the infinite maximum execution time for a CLI request.
I recommend recording this change somewhere in the case of future CI version upgrades however.
For Xampp Users
1. Go to C:\xampp\phpMyAdmin\libraries
2. Open config.default.php
3. Search for $cfg['ExecTimeLimit'] = 300;
4. Change to the Value 300 to 0 or set a larger value
5. Save the file and restart the server
6. OR Set the ini_set('MAX_EXECUTION_TIME', '-1'); at the beginning of your script you can add.
Try something like the following in your script:
set_time_limit(1200);
go to the xampp/phpmyadmin/libraries/config.default.php
and make the following changes
from $cfg['ExecTimeLimit'] = ’300′;
to $cfg['ExecTimeLimit'] = ’0′;
This is the the right answer:
go to
c:\wamp\apps\phpmyadmin3.4.10.1\libraries\config.default.php
find and set
$cfg['ExecTimeLimit'] = 0;
restart all services
and done.
For Local AppServ
Go to C:\AppServ\www\phpMyAdmin\libraries\config.default.php
Find $cfg['ExecTimeLimit'] and set value to 0.
So it'll look like
$cfg['ExecTimeLimit'] = 0;
If xampp in localserver
Goto C:\xampp\phpMyAdmin\libraries\config.default.php
//find $cfg['ExecTimeLimit']= 300;
//increase this value
$cfg['ExecTimeLimit'] = 3000;
So, after spending hours, this works for me (2023)
adding $cfg['ExecTimeLimit'] = 6000; into xampp/phpMyAdmin/config.inc.php
also I change $cfg['ExecTimeLimit'] = 6000; in xampp/phpMyAdmin/libraries/configdefault.php
PHP's CLI's default execution time is infinite.
This sets the maximum time in seconds a script is allowed to run
before it is terminated by the parser. This helps prevent poorly
written scripts from tying up the server. The default setting is 30.
When running PHP from the command line the default setting is 0.
http://gr.php.net/manual/en/info.configuration.php#ini.max-execution-time
Check if you're running PHP in safe mode, because it ignores all time exec settings when on that.
On Xampp, in php.ini you must check mysql.connect_timeout either. So, for example, change it to:
mysql.connect_timeout = 3600
That time will be always counted in seconds (so 1 hour in my example)
MAMP USERS
editing php.ini solves this - there is a line:
max_execution_time = 30 ; Maximum execution time of each script, in seconds
setting this to a higher value worked.
the file is in php/php5.6.25/conf/php.ini (obviousl you need to wet the file for the php version you are using - you can find this out from the MAMP preferences.
If you are on xampp and using phpMyadmin to import large sql files and you have increased max_execution time, max file upload limit and everything needed And If none of the above answers work for you come here
Go to your xampp folder, in my case here is the relative path to the file that I need to modify: C:\xampp\phpMyAdmin\libraries\config.default.php
/**
* maximum execution time in seconds (0 for no limit)
*
* #global integer $cfg['ExecTimeLimit']
* by defautlt 300 is the value
* change it to 0 for unlimited
* time is seconds
* Line 709 for me
*/
$cfg['ExecTimeLimit'] = 0;
WAMP USERS:
1) Go to C:\wamp\apps\phpmyadmin
2) Open config.inc
3) Add $cfg['ExecTimeLimit'] = ’3600′; to the file.
4) Save the file and restart the server.
This file overwrites the php.ini and will work for you!
In my case, when I faced that error in Phpmyadmin, I tried MySQL-Front and import my DB successfully.
Note: You can still use the provided solutions under this question to solve your problem in Phpmyadmin.
If above answers will not work, try to check your code,,In my experience,having an infinite loop will also cause that problem.Check your else if statement.
In Codeignitor version 3.0.x the system/core/Codeigniter.php do not contain the time constraint as well as inserting
ini_set('MAX_EXECUTION_TIME', -1);
will not work since codeignitor will override that with its own function set_time_limit() .
So either you have to delete that function from codeignitor or simply you can insert
set_time_limit('1000');
in the beginning of the php file if you wanna change that to 1000 seconds.
Set the time to 0 (zero) if you want to run it as long as it want.
On wamp in my configuration where I have multiple phpmyadmins, the values in config files were overwritten in wamp/alias/phpmyadmin.conf. I set up two lines there:
1. php_admin_value max_execution_time 3600
2. php_admin_value max_input_time 3600
... it finally worked!
For OpenServer
modules\system\html\openserver\phpmyadmin\libraries\config.default.php
change
$cfg[‘ExecTimeLimit’] = 600
You can set time limit:
ini_set('max_execution_time', 1000000000000000);

Maximum execution time of 300 sec exceeded

Why php always give me that error ? I changed php.ini values to :
max_execution_time = 99999 ;
max_input_time = 99999;
max_input_nesting_level = 64;
memory_limit = 256M;
max_input_vars = 10000;
i have created .htaccess file where i put :
php_value max_execution_time 9999
i have located php.ini 50 times to be sure i am at right location.
I have set :
set_time_limit(9999);
at the begining of my php script.
I have restarted MAMP 50 times, even laptop.
If i use phpinfo(); at the begining of my php script i can see both values (local and master) are set to 99999
I changed phpmyadmin conf located in MAMP\bin\phpMyAdmin\libraries\config.default.php to :
// maximum execution time in seconds (0 for no limit)
$cfg['ExecTimeLimit'] = 0;
But nothing works. Still getting error. Any help is appreciated.
First of all, are you sure you need 300 seconds of execution time? It seems rather impractical to me that a call would take 5 minutes to return an answer. I would recommend looking through your code to make sure there's no infinite loops or the likes anywhere.
Anyways, if your code is working as intended, you should check your php.ini file for another occurrence of max_execution_time which overrides yours, because the default should be at 30 seconds, and not at 300, as far as i know.
Also, you can try adding ini_set('max_execution_time', -1) at the beginning of your code. This drops the maximum execution time entirely.

is it possible to set the SQL execution time in php [duplicate]

I have an XML document that has around 48,000 children (~50MB). I run an INSERT MYSQL query that makes new entries for each one of these children. The problem is that it takes a lot of time due to its size. After it is executed I receive this
Fatal error: Maximum execution time of 60 seconds exceeded in /path/test.php on line 18
How do I set the Maximum execution time to be unlimited?
You can make it by setting set_time_limit in you php code (set to 0 for no limit)
set_time_limit(0);
Or modifying the value of max_execution_time directly in your php.ini
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 120
Or changing it with ini_set()
ini_set('max_execution_time', 120); //120 seconds
but note that for this 3rd option :
max_execution_time
You can not change this setting with ini_set() when running in safe
mode. The only workaround is to turn off safe mode or by changing the
time limit in the php.ini.
Source www.php.net
Put this at the top of your script:
ini_set('max_execution_time', 300);
That'll make it 5 minutes.
You can use the ini_set at the start of your application.
ini_set('max_execution_time', *number of seconds here*); //300 seconds = 5 minutes
You can Set maximum execution time in MYSQL / PHP. it's so easy.
To set maximum execution time in single PHP file, place this code just after your first opening php tag.
ini_set(‘max_execution_time’, 0)
To set maximum execution time in php.ini file. You can set as per your require.
max_execution_time=360 //360 seconds = 6 minutes
To set maximum execution time in htaccess file.
php_value max_execution_time 0
You can also read step by step here.
maximum execution time for Apache Web Server is 300 seconds (5 min), so if your script is very long you have to options
your script can be executed on most 5 minutes
open php.ini file and chanage
max_execution_time = (seconds) for example to max_execution_time = 300
2.if you scripts need mor than 5 minutes you should first change Httpd.conf file (Apache config file)
TimeOut (number of seconds you want)
and also in php.ini max_execution_time = (number of seconds you want)

openfit php fatal error database error [duplicate]

I am downloading a JSON file from an online source and and when it runs through the loop I am getting this error:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\temp\fetch.php on line 24
Your loop might be endless. If it is not, you could extend the maximum execution time like this:
ini_set('max_execution_time', '300'); //300 seconds = 5 minutes
and
set_time_limit(300);
can be used to temporarily extend the time limit.
I had the same problem and solved it by changing the value for the param max_execution_time in php.ini, like this:
max_execution_time = 360 ; Maximum execution time of each script, in seconds (I CHANGED THIS VALUE)
max_input_time = 120 ; Maximum amount of time each script may spend parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB by default)
I hope this could help you.
All the answers above are correct, but I use a simple way to avoid it in some cases.
Just put this command in the begining of your script:
set_time_limit(0);
I ran into this problem while upgrading to WordPress 4.0. By default WordPress limits the maximum execution time to 30 seconds.
Add the following code to your .htaccess file on your root directory of your WordPress Installation to over-ride the default.
php_value max_execution_time 300 //where 300 = 300 seconds = 5 minutes
Edit php.ini
Find this line:
max_execution_time
Change its value to 300:
max_execution_time = 300
300 means 5 minutes of execution time for the http request.
Your script is timing out. Take a look at the set_time_limit() function to up the execution time. Or profile the script to make it run faster :)
if all the above didn't work for you then add an .htaccess file to the directory where your script is located and put this inside
<IfModule mod_php5.c>
php_value post_max_size 200M
php_value upload_max_filesize 200M
php_value memory_limit 300M
php_value max_execution_time 259200
php_value max_input_time 259200
php_value session.gc_maxlifetime 1200
</IfModule>
this was the way I solved my problem , neither ini_set('max_execution_time', 86400); nor set_time_limit(86400) solved my problem , but the .htaccess method did.
We can solve this problem in 3 different ways.
1) Using php.ini file
2) Using .htaccess file
3) Using Wp-config.php file ( for Wordpress )
You can remove the restriction by seting it to zero by adding this line at the top of your script:
<?php ini_set('max_execution_time', '0'); ?>
Follow the path /etc/php5(your php version)/apache2/php.ini.
Open it and set the value of max_execution_time to a desired one.
To extend your max_execution_time you can use either ini_set or set_time_limit.
// Set maximum execution time to 10 seconds this way
ini_set('max_execution_time', 10);
// or this way
set_time_limit(10);
!! But be aware that, both functions restarts also counting of time script has already taken to execute
sleep(2);
ini_set('max_execution_time', 5);
register_shutdown_function(function(){
var_dump(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']);
});
for(;;);
//
// var_dump outputs float(7.1981489658356)
//
so if you want to set exact maximum amount of time script can run, your command must be very first.
Differences between those two functions are
set_time_limit does not return info whether it was successful but it will throw a warning on error.
ini_set returns old value on success, or false on failure without any warning/error
Maybe check for any thing that you have changed under the php.ini file.
For example I changed the ";intl.default_locale =" to ";intl.default_locale = en_utf8" in order to enable the "Internationalization extension (Intl)" without adding the "extension=php_intl.dll" then this same error occurred. So I suggest to check for similar mistakes.
Increase your script execution time by adding the following line at top of the PHP script.
ini_set('max_execution_time', 120); //120 seconds = 2 minutes
Reference has taken from Increase the PHP Script Execution Time
You can do it easily with WHM. Just got to:
WHM -> Service Configuration -> PHP configuration
editor-> max_execution_time=30
( 30 is default change it to whatever value u want)
set_time_limit($time_in_second); // 0 for unlimited time
I use this php function in run time if need to run a script for long.
Details here.
I have same problem in WordPress site,
I added in .htaccess file then working fine for me.
php_value max_execution_time 6000000
I have make some changes in my case in: xampp\phpMyAdmin\libraries\config.default.php
i have searched for : $cfg['ExecTimeLimit'] and change the value at right side...
You can change Right hand Value to any higher value, like '5000'. and it works.

Set maximum execution time in MYSQL / PHP

I have an XML document that has around 48,000 children (~50MB). I run an INSERT MYSQL query that makes new entries for each one of these children. The problem is that it takes a lot of time due to its size. After it is executed I receive this
Fatal error: Maximum execution time of 60 seconds exceeded in /path/test.php on line 18
How do I set the Maximum execution time to be unlimited?
You can make it by setting set_time_limit in you php code (set to 0 for no limit)
set_time_limit(0);
Or modifying the value of max_execution_time directly in your php.ini
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 120
Or changing it with ini_set()
ini_set('max_execution_time', 120); //120 seconds
but note that for this 3rd option :
max_execution_time
You can not change this setting with ini_set() when running in safe
mode. The only workaround is to turn off safe mode or by changing the
time limit in the php.ini.
Source www.php.net
Put this at the top of your script:
ini_set('max_execution_time', 300);
That'll make it 5 minutes.
You can use the ini_set at the start of your application.
ini_set('max_execution_time', *number of seconds here*); //300 seconds = 5 minutes
You can Set maximum execution time in MYSQL / PHP. it's so easy.
To set maximum execution time in single PHP file, place this code just after your first opening php tag.
ini_set(‘max_execution_time’, 0)
To set maximum execution time in php.ini file. You can set as per your require.
max_execution_time=360 //360 seconds = 6 minutes
To set maximum execution time in htaccess file.
php_value max_execution_time 0
You can also read step by step here.
maximum execution time for Apache Web Server is 300 seconds (5 min), so if your script is very long you have to options
your script can be executed on most 5 minutes
open php.ini file and chanage
max_execution_time = (seconds) for example to max_execution_time = 300
2.if you scripts need mor than 5 minutes you should first change Httpd.conf file (Apache config file)
TimeOut (number of seconds you want)
and also in php.ini max_execution_time = (number of seconds you want)

Categories