Bonjour,
je voudrais recuperer des donnees a partir d'une base de donnees MySql, a priori la syntaxe est bonne
echo 'connexion a une base de donnees';
$host="localhost";
$username="root";
$password="";
$database="mabase";
// Start XML file, create parent node
$doc=new DomDocument
("1.0");
$node=$doc->createElement('markers');
$parnode = $doc->appendChild($node);
// Opens a connection to a MySQL server
$connection=mysql_connect ($host, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Select all the rows in the markers table
$query = "SELECT * FROM markers";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
$node = $doc->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['name']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("type", $row['type']);
}
//$xmlfile = $doc->dump_mem(true);
//echo $xmlfile;
echo $doc->saveXML(); quand j'exécute j'obtiens une erreur d'analyse XML,
une aide SVP