...

How do I avoid max execution time errors?

MAtt
10-15-2002, 09:22 AM
Hi, I am writing a script to enter product descriptions into a database. The code used to do this is as follows:

while(list($key, $val) = each($descriptions)) {
$description = explode("," , "$descriptions[$key]");
$description[1] = htmlspecialchars("$description[1]",ENT_QUOTES);
$sql = "UPDATE products SET " .
"Description='$description[1]' " .
"WHERE ProductID='$description[0]'";
$query = mysql_query($sql) or die(mysql_error());
}

The trouble is, i get an error: "Fatal error: Maximum execution time of 30 seconds exceeded in..."
Is there a way I can adjust my code to get rid of this error?
My only idea is to split the descriptions.txt file into multiple files and enter each file into the database separately and I don't think the max execution time can be changed.
Thank you,
Matthew Ruten

Ökii
10-15-2002, 01:41 PM
If you are very confident of the integrity of your code (ie, you are sure the max execution time is surpassed just due to size of update rather than an awkward for loop)...


ini_set(max_execution_time,900);

would give you 15 minutes.

Note: Many hosts will disable client use of ini_set();



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum