I said I'll quit writing.. Well, I was lying then.

PHP error

Tuesday, July 1, 2008

EDIT: Am doing a lot of cURL calls inside a PHP file, around 20-40, causing  the timeout. The PHP file is waiting for the cURLs and all that.

I got this error while doing some stuff:

Fatal error:  Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\kapow\includes\funcs.php in line 53

general form:

Fatal error: Maximum execution time of <max_execution_time> seconds excedeed in C:\<apache server folder>\htdocs\<project folder>\..\<php file> in line <line from php file>

 

So in any case you’d encounter the same (and usual) “maximum execution time” server load error, here’s what you have to do:

Open php.ini and locate variable max_execution_time. Setting it to 5minutes will do the trick. It’s safest to allot more time.

max_execution_time = 300              ; Maximum execution time of each script, in seconds

max_input_time = 300                         ; Maximum amount of time each script may spend parsing request data

If you are using XAMPP, change the following php.ini files:

 C:\xampp\apache\bin\php.ini

 C:\xampp\php\php4\php4.ini

C:\xampp\php\php4\php.ini

C:\xampp\php\php.ini

And of course, don’t forget to restart your Apache server. 

Hope that helps.  :)


Posted by caiabbass at 3:31 pm | permalink

Previous Comments

So far I haven’t encoutered that error since I’ve been using XAMPP on both windows and ubuntu OS

Posted by Cesar Noel at July 2, 2008, 9:27 am

you must be running a pretty complex script. unless you’re generating a big report, the 60 seconds execution time limit should be enough. Try optimizing your script a little, or use 3rd party extensions like eAccelerator. I think XAMPP has eAccelerator bundled.

BTW, nice blog.

Posted by Pao at July 2, 2008, 12:39 pm

Hi Pao,

For this case, i think something like eAccelerator will not help. it’s not helping because am running a bot from a third party.

what else can i do?

Posted by Cai at July 2, 2008, 3:28 pm

hi cai :)

in general, it’s bad to resort to modifying php.ini just because you can’t make your script work or run fast. global configuration file kasi yung php.ini, in real life situations may mga iba pang php scripts na tumatakbo sa server aside from your own scripts, if you just modified php.ini then maaapektuhan din sila, baka magkaroon pa ng bad consequences for those scripts…(assuming that you even had the permission to modify php.ini)

kung nagta-timeout yung php script mo, i suggest i-check mo muna kung may problem sa mga for/while loops mo, baka yun ang kailangan mong i-optimize muna. kung wala, then check mo kung mabagal yung site na fine-fetch ng curl call mo. in that case, adjust mo yung timeout ng curl call mo (try “curl_setopt($ch, CURLOPT_TIMEOUT, $new_timeout), etc”), wag mong patagalin mag-execute yung curl functions mo. puwede ka rin gumamit ng caching techniques (Cache_Lite pear module, etc).

then if after you’ve done those eh nagta-timeout pa rin ang mismong script mo, i suggest gumawa ka ng “.htaccess file” sa directory ng script mo, tapos lagyan mo ng ganitong entries:


php_value max_execution_time 300
php_value max_input_time 300

that way, yung script mo lang ang maaapektuhan. :-)

Posted by perryv at July 3, 2008, 7:47 pm

@perryv - thanks for the info but yeah, nimodify ko na. binalik ko na ung original na timeout sa ini files kasi i realized the same thing na sinabi mo.

hindi si curl ung may problema, i have 200 - 400 curl calls kaya mahaba ung hinihintay ni php script, kaya ang ginawa ko nagset na lang ako using set_time_limit() para sa concerned script lang.

Posted by Cai at July 4, 2008, 12:47 am

ah, 200 to 400 curl calls ba? akala ko “20 to 40″ curl calls lang (see your Edit: paragraph on your post). super dami ah? :)

captcha: blare :)

Posted by perryv at July 4, 2008, 1:02 am

by the way, mas maganda yung solution mo using set_time_limit(), no need to mess around apache’s config files. :)

captcha: heard :)

Posted by perryv at July 4, 2008, 1:13 am

thanks perryv :)

Posted by caiabbass at July 4, 2008, 1:38 am

bad program design creates memory intensive calls. basically you rarely need to modify the config file ,running cURL on the command line and
firing curl requests in parallel will be the best approach :-) have fun

Posted by Finch at July 4, 2008, 3:50 pm

next code please!

Posted by dimaks at July 6, 2008, 5:18 pm

Si Dimaks naghahanap na naman ng bagong post, hahahahaha

Posted by Cai at July 6, 2008, 6:13 pm

All comments are moderated. Your comments will not appear here unless approved by the blog owner. Thank you.

Add a comment








     

July 2008
M T W T F S S
« Jun   Aug »
 123456
78910111213
14151617181920
21222324252627
28293031  

iDisclose

    

Subscribe

Technorati
Bloglines

MyBlogLog

Analytics

Recommendations