I'm getting the following error message:
Warning: file_get_contents(http://localhost/sample_pie.php) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\EXACT\report.php on line 206
Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\EXACT\report.php on line 206
Here is the line 206:
$url = 'http://localhost/sample_pie.php';
$img = 'C:\xampp\htdocs\piechart.jpg';
file_put_contents($img, file_get_contents($url));
What do I have to do to fix this?
Just increase the max_execution_time in php. ini. Set it to 1800 and restart your apache or any other server you are using. Save this answer.
Look for : $cfg['ExecTimeLimit'] = 600; You can change '600' to any higher value, like '6000'. Maximum execution time in seconds is (0 for no limit). This will fix your error.
You can call set_time_limit(0) to remove the time limit from the rest of the execution, or you can call set_time_limit(n) in each iteration of a loop (for example) to reset the timer for n more seconds. Save this answer.
Your script executed for more then 60 seconds and was terminated. There is a value in php.ini defining maximum time PHP script can run. The purpose of this is to prevent scripts from hanging. You could try to optimize your script but if it's intended to run for so long you can just update the value (it's called max_execution_time
).
You can also try changing this value for particular script by running set_time_limit() function, docs here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With