• When downloading a JSON file from an online source and it runs through the loop 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:

 

php code
                    ini_set('max_execution_time', 300); //300 seconds = 5 minutes
[ad type=”banner”]

  • we solved it by changing the value for the param max_execution_time in php.ini, like this:
php code
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)

  • Just put this command in the begining of your script:

 

php code
                              set_time_limit(0);

  • Edit php.ini
  • Find this line:
php code
               max_execution_time
  • Change its value to 300:
php code
max_execution_time = 300
  • 300 means 5 minutes of execution time for the http request.

  • In 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 code
php_value max_execution_time 300  //where 300 = 300 seconds = 5 minutes
[ad type=”banner”]

  • You add an .htaccess file to the directory where your script is located and put this inside
php code
<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>
  • Neither ini_set(‘max_execution_time’, 86400); nor set_time_limit(86400) solved my problem , but the .htaccess method did.

  • Neither ini_set(‘max_execution_time’, 86400); nor set_time_limit(86400) solved my problem , but the .htaccess method did.
php code
ini_set('max_execution_time', 120); //120 seconds = 2 minutes

  • You can remove the restriction by setting it to zero by adding this line at the top of your script:
php code
<?php ini_set('max_execution_time', 0); ?>
[ad type=”banner”]

  • 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.

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 )

Categorized in: