Maximum execution time of 30 seconds exceeded

Posted on 2012-08-17
Medium Priority
Last Modified: 2012-08-17
$mysqli = new mysqli('localhost', 'root', '', 'db_543216');
if ( $mysqli->connect_errno ) {
    die("Connect error (". $mysqli->connect_errno .") ". $mysqli->connect_error);
echo "<pre>";

$filename = '../imedia/DB/'.$baz.'/artiklisl.xml';
if (file_exists($filename)) {if ( $xml = simplexml_load_file($filename)){
 $sql = "INSERT INTO artiklisl (ID,IDA,IDJ,kolicina) VALUES (?,?,?,? )";
  $stmt = $mysqli->prepare($sql);
 $total = 0;
   foreach ( $xml->xpath('//Table1') as $ele ) {
            $ID         = $ele->ID;
            $IDA        = $ele->IDA;
            $IDJ        = $ele->IDJ;
            $kolicina   = $ele->kolicina;
            $total += $stmt->affected_rows;
        } echo "artiklisl Failed Total rows inserted = $total", PHP_EOL;
    } else {
        echo("artiklisl Failed to load $filename.");
} else {
    echo("artiklisl File $filename was not found.");

ther is SQL for create MYSQL table

CREATE TABLE `artiklisl` (
  `ID` int(11) DEFAULT NULL,
  `IDA` int(11) DEFAULT NULL,
  `IDJ` int(11) DEFAULT NULL,
  `kolicina` float DEFAULT NULL
Question by:cnermin
  • 4
  • 3
LVL 58

Expert Comment

ID: 38306506
Increase the timeout in php.ini
max_execution_time =  // value here

or on the page itself

ini_set('max_execution_time', 120);  //value in seconds
LVL 35

Expert Comment

ID: 38306570
On the page itself, use set_time_limit():

LVL 58

Expert Comment

ID: 38306608
Though if you are on shared hosting you may not be able to change the timeout and may have to speak to your host.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 38306624
correctly and

 ini_set('max_execution_time', 120);



i am on shared host. is it possible to set on page only for one action

Author Comment

ID: 38306628
now work local but after that i should put online
LVL 58

Accepted Solution

Gary earned 1500 total points
ID: 38306640
Add the same code (with the new value) after the code you want to increase the timeout for.
You only need to use either ini_set or set_time_limit - not both.

Author Comment

ID: 38306822
is it  possible it for 2000 record from xml to mysql in php execution time of 30 seconds exceeded
LVL 58

Expert Comment

ID: 38306830
Possible, depends on the data in the xml.
You are also running on your own machine so its probably not tuned as a server which would be faster at processing things (and you probably have other programs running slowing down your pc)

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question