Jump to content

Internal Server Error / Script Timeout


SupaMonkey

Recommended Posts

So I have a script that goes to a page and rips it of all the numbers and then goes onto the next page, etc etc. Basically the script works 100% and I can do up to about 90 pages at a time; as soon as I try and do any more than that - I get an "Internal Server Error" after a while. I tried the whole ob_start / flush theory which is supposedly supposed to work and it hasnt. Any idea's?
- PHP is installed as CGI
- Running Apache
- Script is run off a local webserver and connects to remote page

Here is my script:
[code]$none_found = '';
$found_num = '';
$found_at = '';

set_time_limit(9000);
ob_start();

for ($i = 1; $i <= 90; $i++)
{
    $fh         = fopen("http://www.someplace.com/index.php?id=". $i,'r');
    $result = '';

    while(!feof($fh))
     $result .= fgets($fh);

    fclose($fh);

    $message = strip_tags($result);

    if (preg_match("|\d{3} \d{3} \d{4}|", $message, $numbers_found))
    {
        $found_at  .= $i .",";
        $found_num .= $numbers_found[0] .'<br>';
        mysql_query('insert into zzz_numbers (cellphone) values (\''. $numbers_found[0] .'\')');
    }
    else
        $none_found .= $i .',';
    
    if (substr($i,strlen($i)-1) == '0')
    {
      echo ".";
        
    flush();
    ob_flush();
    }
    sleep(1);
}
echo "<br><br>None found at:<br>". $none_found;
echo "<br><br>Found at:<br>". $found_at;
echo "<br><br>Numbers found :<br>". $found_num;
[/code]
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.