I need to generate a XML file from a Database, I wrote this PHP code, but it's showing nothing. I first thought the problem was because of a bad connection/query, but that's not the problem. They are both working fine.
I think the problem is the "mysql_fetch_assoc($result)", but I'm not sure because can't really fix it!
<?php
$con = new mysqli('localhost', 'root', 'usbw', 'bierdb', 3307);
$query = "SELECT biernaam, kleur FROM bier";
$result = $con ->query($query);
$xml = new XMLWriter();
$xml->openURI("bieren.xml");
$xml->startDocument();
$xml->setIndent(true);
$xml->startElement('kaart');
if(is_resource($result)) {
while ($row = mysql_fetch_assoc($result)) {
$xml->startElement("Bier");
$xml->writeAttribute('kleur', $row['kleur']);
$xml->writeRaw($row['biernaam']);
$xml->endElement();
}
$xml->endElement();
header("Content-Type:text/xml");
echo $xml->flush();
}
?>
Thanks for reading and helping me, I appreciate it!