Jump to content

max_execution_time bypass


php new bie

Recommended Posts

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

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>";
}

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.