Lucas Salatiel
New Member
I am getting the 500 internal Server Error while using file_get_contents in a loop to get arroung 40,000 records. My code is as follows -\[code\]$roll=1;while($roll<=40000){ $data=http://stackoverflow.com/questions/10562709/array(); $postdata = http_build_query( array('regno' => $roll ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('http://myurl', false, $context); $sql = "INSERT INTO `mytable` (rolll) value ('".$result."')"; mysql_query($sql); $roll = $roll + 1;}\[/code\]All my code is working properly and also the records are inserting in my table.But after inserting around 200 to 300 records I got an error asInternal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator, webmaster@myurl and inform them of the time the error occurred, and anything you might have done that may have caused the error.More information about this error may be available in the server error log.Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.Can anyone guide me how to handle this problem.Thanking You.