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

 

[pastacode lang=”php” manual=”%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ini_set(‘max_execution_time’%2C%20300)%3B%20%2F%2F300%20seconds%20%3D%205%20minutes%0A” message=”php code” highlight=”” provider=”manual”/] [ad type=”banner”]

  • we solved it by changing the value for the param max_execution_time in php.ini, like this:
[pastacode lang=”php” manual=”max_execution_time%20%3D%20360%20%20%20%20%20%20%3B%20Maximum%20execution%20time%20of%20each%20script%2C%20in%20seconds%20(I%20CHANGED%20THIS%20VALUE)%0Amax_input_time%20%3D%20120%20%20%20%20%20%20%20%20%20%20%3B%20Maximum%20amount%20of%20time%20each%20script%20may%20spend%20parsing%20request%20data%0A%3Bmax_input_nesting_level%20%3D%2064%20%3B%20Maximum%20input%20variable%20nesting%20level%0Amemory_limit%20%3D%20128M%20%20%20%20%20%20%20%20%20%20%20%3B%20Maximum%20amount%20of%20memory%20a%20script%20may%20consume%20(128MB%20by%20default)%0A” message=”php code” highlight=”” provider=”manual”/]

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

 

[pastacode lang=”php” manual=”%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20set_time_limit(0)%3B%0A” message=”php code” highlight=”” provider=”manual”/]

  • Edit php.ini
  • Find this line:
[pastacode lang=”php” manual=”%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_execution_time%0A” message=”php code” highlight=”” provider=”manual”/]
  • Change its value to 300:
[pastacode lang=”php” manual=”max_execution_time%20%3D%20300″ message=”php code” highlight=”” provider=”manual”/]
  • 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.
[pastacode lang=”php” manual=”php_value%20max_execution_time%20300%20%20%2F%2Fwhere%20300%20%3D%20300%20seconds%20%3D%205%20minutes%0A” message=”php code” highlight=”” provider=”manual”/] [ad type=”banner”]

  • You add an .htaccess file to the directory where your script is located and put this inside
[pastacode lang=”php” manual=”%3CIfModule%20mod_php5.c%3E%0Aphp_value%20post_max_size%20200M%0Aphp_value%20upload_max_filesize%20200M%0Aphp_value%20memory_limit%20300M%0Aphp_value%20max_execution_time%20259200%0Aphp_value%20max_input_time%20259200%0Aphp_value%20session.gc_maxlifetime%201200%0A%3C%2FIfModule%3E%0A” message=”php code” highlight=”” provider=”manual”/]
  • 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.
[pastacode lang=”php” manual=”ini_set(‘max_execution_time’%2C%20120)%3B%20%2F%2F120%20seconds%20%3D%202%20minutes” message=”php code” highlight=”” provider=”manual”/]

  • You can remove the restriction by setting it to zero by adding this line at the top of your script:
[pastacode lang=”php” manual=”%3C%3Fphp%20ini_set(‘max_execution_time’%2C%200)%3B%20%3F%3E%0A” message=”php code” highlight=”” provider=”manual”/] [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: