Jump to content

file_get_contents getting 500 Error


db323c

Recommended Posts

Trying to create a script to grab all the threads from a forum and put them in a db to search through later. Everything seems to work except that I get a 500 internal server error after 5-10 minutes.

 

 

      set_time_limit(0);

       mysql_query("Truncate table forumindex");

        //#of threads
for($x=1; $x<40000; $x++)
{	
        //multiple forums
	for($i=0; $i<4; $i++)
	{	
	        //initial thought was a timeout issue, so I tried to solve that.
		$ctx = stream_context_create(array(
		    ‘http’ => array(
		        ‘timeout’ => 3
		        )
		    )
		);
		$handle = file_get_contents("http://*********.com/boardthread?id=" . $forum[$i] . "&thread=" . $x, null, $ctx);


		if($handle)
		{
			//code  to add to db. which works.				
		}
	}		
}

 

Link to comment
https://forums.phpfreaks.com/topic/195036-file_get_contents-getting-500-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.