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.'/art iklisl.xml ';
if (file_exists($filename)) {if ( $xml = simplexml_load_file($filen ame)){
$sql = "INSERT INTO artiklisl (ID,IDA,IDJ,kolicina) VALUES (?,?,?,? )";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('ssss',$ ID,$IDA,$I DJ,$kolici na);
$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
$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.'/art
if (file_exists($filename)) {if ( $xml = simplexml_load_file($filen
$sql = "INSERT INTO artiklisl (ID,IDA,IDJ,kolicina) VALUES (?,?,?,? )";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('ssss',$
$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
On the page itself, use set_time_limit():
set_time_limit(120);
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.
ASKER
correctly and
ini_set('max_execution_tim e', 120);
and
set_time_limit(120);
i am on shared host. is it possible to set on page only for one action
ini_set('max_execution_tim
and
set_time_limit(120);
i am on shared host. is it possible to set on page only for one action
ASKER
now work local but after that i should put online
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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)
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)
max_execution_time = // value here
or on the page itself
ini_set('max_execution_tim