php new bie Posted July 10, 2008 Share Posted July 10, 2008 hello , if i have acode like this : <?php block of code depends [if this got max execution time Fatal Error obtained preventing the rest of script to load , so my Question how can i make conditional statement to till if max execution time exceeded just complete the rest ?] ////////// other block of code ?> thanks Quote Link to comment https://forums.phpfreaks.com/topic/114037-max_execution_time-bypass/ Share on other sites More sharing options...
Lamez Posted July 10, 2008 Share Posted July 10, 2008 I do not understand. Quote Link to comment https://forums.phpfreaks.com/topic/114037-max_execution_time-bypass/#findComment-586127 Share on other sites More sharing options...
Third_Degree Posted July 10, 2008 Share Posted July 10, 2008 I do not fully understand your problem, but adding the line set_time_limit( 0 ); at the top of the page may solve your problem. Quote Link to comment https://forums.phpfreaks.com/topic/114037-max_execution_time-bypass/#findComment-586128 Share on other sites More sharing options...
php new bie Posted July 10, 2008 Author Share Posted July 10, 2008 i mean how to prevent the Fatal error and make the script complete loading <=- this is the main idea . in my case : 1st of the code make external connections , which my be down or slow so [fatal error appears and avoid the next block of code which work fine] . the bottom of code works fine localy , so no problem with max-execution_time . thank you all of you for quick reply Quote Link to comment https://forums.phpfreaks.com/topic/114037-max_execution_time-bypass/#findComment-586129 Share on other sites More sharing options...
Third_Degree Posted July 10, 2008 Share Posted July 10, 2008 if the second part of your code is in no way dependent on the top, then put it first? Otherwise, you could use the @ operator in front functions like fsockopen etc. Post code? Quote Link to comment https://forums.phpfreaks.com/topic/114037-max_execution_time-bypass/#findComment-586133 Share on other sites More sharing options...
php new bie Posted July 10, 2008 Author Share Posted July 10, 2008 this code get the no. of results obtained by using google search the 2nd part inserts them to DB , which works on the local host [server or PC] , some servers show me fatal error due to max_execution_time of the function 'file_get_contents' ,BTW 'set_time_limit' NOT work when safe mode ON ? <html> <center> <form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>"> <br> Get google page results for the term word ? <br> <br> <input type="text" name="x"> <br> <br> <input type="submit" name="submit" value="Get results now!"> </form> </center> </html> <?php if (isset($_POST['x'])){ $x=$_POST['x']; } if(isset($x)){ $n = str_replace(" ","+",$x); $q=file_get_contents("http://www.google.com/search?hl=en&q=$n&btnG=Search"); $sp = "about <b>(.*)<\/b> for"; $num = ereg($sp,$q,$reg); if ($num) { echo "<center><br /><font color=green" . substr($reg[0] , 5 , -3) . "</font></center>" ; } else { echo "<center>No result Founded !</center>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/114037-max_execution_time-bypass/#findComment-586136 Share on other sites More sharing options...
Third_Degree Posted July 10, 2008 Share Posted July 10, 2008 try ini_set( "max_execution_time", "99999" ); Quote Link to comment https://forums.phpfreaks.com/topic/114037-max_execution_time-bypass/#findComment-586137 Share on other sites More sharing options...
php new bie Posted July 10, 2008 Author Share Posted July 10, 2008 ok , i will try . Thanks Third_Degree Quote Link to comment https://forums.phpfreaks.com/topic/114037-max_execution_time-bypass/#findComment-586142 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.