<?php
$dbh = new PDO("mysql:host=localhost;dbname=1callorders", "root", "xxxx");
$i = 1;
do {
echo $i;
if($_GET['xmlfile'.$i]!=""){ // check if the value is empty
$file = $_GET['xmlfile'.$i];
// SKIP THE EMPTY FILE POSITIONS
//if (empty($file)) continue;
$filepath = "xmlimport/";
}
$xml = file_get_contents($filepath . $file);
$obj = simplexml_load_string($xml);
//echo out statements from xml
//$name = (string)$obj->header->manifest->document->name;
//$orderdesc = (string)$obj->body->ORDER->ORDERHEAD->ORDERDESC;
//$orderdesc2 = (string)$obj->body->ORDER->ORDERHEAD->FUNCDESC;
$space = " ";
//echo "Name: " . $name . $space;
//echo "Desc: " . $orderdesc . $space;
//echo "Desc2: " . $orderdesc2 . $space;
//end statements
//prepare the query
$stmt = $dbh->prepare("INSERT INTO ret_orders (ret_id, ord_prodtpe, ord_prodcdedesc, ord_proddesc) VALUES (:ret_id, :name, :orderdesc, :orderdesc2)");
//bind the named parameter to a PHP variable (called $name and $orderdesc etc )
$stmt->bindParam('ret_id', $ret_id);
$stmt->bindParam('name', $name);
$stmt->bindParam('orderdesc', $orderdesc);
$stmt->bindParam('orderdesc2', $orderdesc2);
$ret_id = "DRM";
$name = (string)$obj->header->manifest->document->name;
$orderdesc = (string)$obj->body->ORDER->ORDERHEAD->ORDERDESC;
//$orderdesc2 = (string)$obj->body->ORDER->ORDERHEAD->FUNCDESC;
//loop through the orderline to get each product description
foreach ($obj->body->ORDER->ORDERLINE as $orderline):
$orderdesc2 = $orderline->PRODUCT->DESCRIPTION;
//execute the query
$stmt->execute();
endforeach;
//run the second query
//$stmt2 = $dbh->prepare("INSERT INTO ret_orders (ord_linetype) VALUES (:name)");
//$stmt2->bindParam('name', $name);
///$stmt2->execute();
$i++;
} while ($i <= 5);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body><br /><br />
<?php
$i = 1;
$break = "<br />";
$space = " ";
do {
//echo $i;
if($_GET['xmlfile'.$i]!=""){ // check if the value is empty
$filenames = $_GET['xmlfile'.$i];
}
echo "File Imported:".$space.$filenames.$break;
$i++;
} while ($i <= 5);
?>
</body>
</html>
Your code on 12/13 works in terms of entering the correct data into the database but the page hangs after the url data is parsed to it and the code from lines 78 onwards does not show on the page
where exactly should the second } bracket be in your code - could you edit the page to demonstrate please