Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Location
    small town saskatchewan
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I avoid max execution time errors?

    Hi, I am writing a script to enter product descriptions into a database. The code used to do this is as follows:
    PHP Code:
        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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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();
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •