Link to home
Start Free TrialLog in
Avatar of cnermin
cnermin

asked on

Maximum execution time of 30 seconds exceeded

<?php
$baz='543216';
$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);
$stmt->bind_param('ssss',$ID,$IDA,$IDJ,$kolicina);
 $total = 0;
   foreach ( $xml->xpath('//Table1') as $ele ) {
            $ID         = $ele->ID;
            $IDA        = $ele->IDA;
            $IDJ        = $ele->IDJ;
            $kolicina   = $ele->kolicina;
            $stmt->execute();
            $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
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
artikliSL.xml
Avatar of Gary
Gary
Flag of Ireland image

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
On the page itself, use set_time_limit():

set_time_limit(120);
Though if you are on shared hosting you may not be able to change the timeout and may have to speak to your host.
Avatar of cnermin
cnermin

ASKER

correctly and

 ini_set('max_execution_time', 120);

   and

set_time_limit(120);

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

ASKER

now work local but after that i should put online
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cnermin

ASKER

is it  possible it for 2000 record from xml to mysql in php execution time of 30 seconds exceeded
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)