JamesFlowers
Programmer
Hi , I am trying to export from MySQL to a XML using code below , and it returns
"Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference on line 20"
any ideas please?
TIA
James Flowers
Crystal Consultant
"Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference on line 20"
any ideas please?
TIA
Code:
<?php
//Create Database connection
$db = mysql_connect('XXXXXXXXXX','XXXXXXXXXX','XXXXXXXXXX');
if (!$db) {
die('Could not connect to db: ' . mysql_error());
}
//Select the Database
mysql_select_db('XXXXXXXXXX') or die (mysql_error());
$result = mysql_query("select CustomerName from Customers", $db);
//Create SimpleXMLElement object
$xml = new SimpleXMLElement('<xml/>');
//Add each column value a node of the XML object
while($row = mysql_fetch_assoc($result)) {
$mydata = $xml->addChild('mydata');
$mydata->addChild('Name',$row['CustomerName']);
}
mysql_close($db);
//Create the XML file
$fp = fopen("employeeData.xml","wb");
//Write the XML nodes
fwrite($fp,$xml->asXML());
//Close the database connection
fclose($fp);
?>
James Flowers
Crystal Consultant