Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7047129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:44:01+00:00 2026-05-28T02:44:01+00:00

I’m getting the 500 Internal Server Error by running the following script, even though

  • 0

I’m getting the 500 Internal Server Error by running the following script, even though I’m downloading and inserting to the DB 80 images at a time:

<?php

function download_remote_file($file_url, $save_to)
{
    $content = file_get_contents($file_url);
    file_put_contents($save_to, $content);
}

function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}

require_once('sqlconnect.php');
$time_start = microtime_float();
$query="SELECT * FROM GAMES WHERE GAME_IMAGE LIKE '%cache%' LIMIT 0, 80";

$result = mysql_query($query);

while($row = mysql_fetch_array($result))
{
  $game_img = $row['GAME_IMAGE'];
  $gameDB_id = $row['GAME_DBID'];
  chdir($_SERVER['DOCUMENT_ROOT'].'/img/game/');
  if(!file_exists($gameDB_id))
  {
  mkdir($gameDB_id);
  }
  if(strlen(strstr($game_img,'boxart')) == 0)
  {
      $game_img = $game_img.'/boxart/original/front/'.$gameDB_id.'-1.jpg'; 
  }

  $game_img_path = $_SERVER['DOCUMENT_ROOT'].'/img/game/'.$gameDB_id;
  chmod($game_img_path,0777);
  $game_img_name = $gameDB_id.'.jpg';
 $gamefullpath = 'http://www.someSite.nl/img/game/'.$gameDB_id.'/'.$game_img_name;
 if(!file_exists($game_img_path.'/'.$game_img_name ))
 {
  download_remote_file($game_img, realpath($game_img_path) . '/'.$game_img_name); 

  $bytes = filesize($game_img_path.'/'.$game_img_name );
  $KB = round($bytes / 1024, 2);
  if($KB > 50)
  {
      echo "The ID number ".$gameDB_id. " has an invalid image URL, look it up on gamedb.net! <br />";
  }
 }
   $query2 = "UPDATE GAMES SET GAME_IMAGE = '$gamefullpath' WHERE GAME_DBID = '$gameDB_id' AND GAME_DBID";
  $result2 = mysql_query($query2) or die("error!");
  //$nr_of_files = count($game_img_path);
  //echo "Nr of images downloaded:".$nr_of_files;
}

mysql_close($con);
$time_end = microtime_float();
$time = $time_end - $time_start;

echo "Downloading and adding to the database took ".$time." seconds <br />";
$message = "The specified images have been downloaded!";
echo $message;
?>

Am I doing something wrong which forces the server to stop? Or in case it’s not efficient what can I do to make it so. Or maybe the problem is some server configuration.

Server:

Apache/2.2.9 (Debian) DAV/2 SVN/1.5.1 PHP/5.2.6-1+lenny13 with Suhosin-Patch mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11) mod_ssl/2.2.9 OpenSSL/0.9.8g Server

Your help is much appreciated.

UPDATE (log):

‎[Wed Jan 11 08:58:39 2012] [notice] mod_fcgid: call /home/someSiteName/public_html/admin/download_game_img.php with wrapper /home/someSiteName/fcgi-bin/php5.fcgi

UPDATE (time):

about 100 seconds.

UPDATE (die):

I put a die after this line and the error seems to be here:

download_remote_file($game_img, realpath($game_img_path) . '/'.$game_img_name);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:44:02+00:00Added an answer on May 28, 2026 at 2:44 am

    this is because the default php script’s maximum execution time is 30 seconds and your page is taking more than 100 seconds.

    you can increase the maximum execution time for your php scripts using .htaccess file

    add the following lines to your .htaccess file

    php_value max_execution_time 8000
    php_value max_input_time 4000
    

    you can also set the limit in php.ini file

    max_execution_time 8000
    max_input_time 4000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.