0

I've put together a script which allows me to upload an XML file to a mySQL database. The problem I'm having is that after approximately 15 seconds I receive the 'Internet Explorer cannot display the webpage' screen.

Because the file is a little over 5MB I've assumed that the issue is to do with either a 'timeout' or 'filesize' issue within PHP. After some research I thought I'd found a way of changing this, hopefully enabling me to download the file so I inserted these lines at the top of my PHP script.

ini_set('max_execution_time', 300); //300 seconds = 5 minutes
ini_set('memory_limit', '6M'); //6 MB

I've now reloaded the files, and my server, but I'm still getting the same problem and I've run out of why this may be happening.

PHP Code

<? 

ini_set('max_execution_time', 300); //300 seconds = 5 minutes
ini_set('memory_limit', '6M'); //6 MB
  $objDOM = new DOMDocument(); 
  $objDOM->load("xmlfile.xml"); 

  $Details = $objDOM->getElementsByTagName("Details"); 

  foreach( $Details as $value ) 
  { 

    $listentry = $value->getElementsByTagName("listentry"); 
    $listentrys  = $listentry->item(0)->nodeValue;

    $sitetype = $value->getElementsByTagName("sitetype"); 
    $sitetypes  = $sitetype->item(0)->nodeValue;

    $sitedescription = $value->getElementsByTagName("sitedescription"); 
    $sitedescriptions  = $sitedescription->item(0)->nodeValue;

    $siteosgb36lat = $value->getElementsByTagName("siteosgb36lat"); 
    $siteosgb36lats  = $siteosgb36lat->item(0)->nodeValue;

    $siteosgb36lon = $value->getElementsByTagName("siteosgb36lon"); 
    $siteosgb36lons  = $siteosgb36lon->item(0)->nodeValue;

    //echo "$listentrys :: $sitetypes :: $sitedescriptions :: $siteosgb36lats :: $siteosgb36lons <br>"; 
require("phpfile.php");

//Opens a connection to a MySQL server
$connection = mysql_connect ("hostname", $username, $password);
if (!$connection) {
 die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}

mysql_query("INSERT IGNORE INTO scheduledsites (listentry, sitetype, sitedescription, siteosgb36lat, siteosgb36lon) VALUES('$listentrys','$sitetypes','$sitedescriptions','$siteosgb36lats','$siteosgb36lons') ")  
or die(mysql_error());  

  } 

echo "Data Inserted!"; 


?>
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
IRHM
  • 1,326
  • 11
  • 77
  • 130
  • How do you save the XML in your DB? Make sure the max size of the filetype is big enough. Blob won't be, bigblob will. –  Jan 06 '12 at 15:37
  • Hi @rsplak. Many thanks for replying to my post. The file originally starts in Excel where I run some macros to sort out the data I want to use. I then save the file as an XML Data file and run a PHP script to load into the database. I've added the code to my original post. I'm pretty sure the way I upload the file is ok as I upload another file, although considearbly smaller, and this runs without any issues. Kind regards. – IRHM Jan 06 '12 at 15:46

1 Answers1

0

You can try this suggestion which I provided to another StackOverflow member the other day:

Add this to an htaccess file:

<IfModule mod_php5.c>
php_value post_max_size 200M
php_value upload_max_filesize 200M
php_value memory_limit 300M
php_value max_execution_time 259200
php_value max_input_time 259200
php_value session.gc_maxlifetime 1200
</IfModule>

Read more about those settings at http://www.pacecode.com/blog/2008/09/22/magic-with-htaccess-file-increase-execution-time-session-expiry-time-and-file-upload-size-limit/

Community
  • 1
  • 1
Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133
  • Hi @cillosis, forgive me for asking. Being a little new to this area, could you perhaps explain how I would access the 'htaccess' file? Many thanks and kind regards – IRHM Jan 06 '12 at 16:01
  • This is probably better explained with a tutorial: http://www.htaccess-guide.com/ – Jeremy Harris Jan 06 '12 at 16:03