Hi All,
i am trying to create an xml file from several db queries but im having a few problems.
here is my code
but when it creates the link to view the xml is says
not sure where im going wrong? any help is appreciated
thanks
Luke
i am trying to create an xml file from several db queries but im having a few problems.
here is my code
PHP Code:
<?php require_once('dbinfo.php');?>
<!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>
<?php
$file= fopen("index_latest_results.xml", "w");
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$_xml .="<site>\r\n";
$query = mysql_query("
SELECT filmID as id, filmName as name, filmBinding as binding, filmThumbIMG as img, filmReleaseDate as releasedate
FROM tbl_dvds
WHERE filmReleaseDate >= curdate() and filmReleaseDate <= DATE_ADD(curdate(),INTERVAL 7 day)") or die (mysql_error());
while($row = mysql_fetch_array($query))
{
$_xml .="\t<product>\r\n";
$_xml .="\t<title>" . $row["name"] . "</title>\r\n";
$_xml .="\t<binding>" . $row["binding"] . "</binding>\r\n";
$_xml .="\t<image>" . $row["img"] . "</image>\r\n";
$_xml .="\t<release date>" . $row["releasedate"] . "</release date>\r\n";
$_xml .="\t</product>\r\n";
}
$query2 = mysql_query("
SELECT cdID as id, cdName as name, cdBinding as binding, cdThumbIMG as img, cdReleaseDate as releasedate
FROM tbl_cds
WHERE cdReleaseDate >= curdate() and cdReleaseDate <= DATE_ADD(curdate(),INTERVAL 7 day)") or die (mysql_error());
while($row = mysql_fetch_array($query2))
{
$_xml .="\t<product>\r\n";
$_xml .="\t<title>" . $row["name"] . "</title>\r\n";
$_xml .="\t<binding>" . $row["binding"] . "</binding>\r\n";
$_xml .="\t<image>" . $row["img"] . "</image>\r\n";
$_xml .="\t<release date>" . $row["releasedate"] . "</release date>\r\n";
$_xml .="\t</product>\r\n";
}
$query3 = mysql_query("
SELECT gameID as id, gameName as name, gameBinding as binding, gameThumbIMG as img, gameReleaseDate as releasedate
FROM tbl_games
WHERE gameReleaseDate >= curdate() and gameReleaseDate <= DATE_ADD(curdate(),INTERVAL 7 day)") or die (mysql_error());
while($row = mysql_fetch_array($query3))
{
$_xml .="\t<product>\r\n";
$_xml .="\t<title>" . $row["name"] . "</title>\r\n";
$_xml .="\t<binding>" . $row["binding"] . "</binding>\r\n";
$_xml .="\t<image>" . $row["img"] . "</image>\r\n";
$_xml .="\t<release date>" . $row["releasedate"] . "</release date>\r\n";
$_xml .="\t</product>\r\n";
}
$query4 = mysql_query("
SELECT bookID as id, bookName as name, bookBinding as binding, bookThumbIMG as img, bookReleaseDate as releasedate
FROM tbl_books
WHERE bookReleaseDate >= curdate() and bookReleaseDate <= DATE_ADD(curdate(),INTERVAL 7 day)") or die (mysql_error());
while($row = mysql_fetch_array($query4))
{
$_xml .="\t<product>\r\n";
$_xml .="\t<title>" . $row["name"] . "</title>\r\n";
$_xml .="\t<binding>" . $row["binding"] . "</binding>\r\n";
$_xml .="\t<image>" . $row["img"] . "</image>\r\n";
$_xml .="\t<release date>" . $row["releasedate"] . "</release date>\r\n";
$_xml .="\t</product>\r\n";
}
$_xml .="\t</site>\r\n";
fwrite($file, $_xml);
fclose($file);
echo "XML has been written. <a href=\"index_latest_results.xml\">View the XML.</a>";
?>
</body>
</html>
Code:
XML Parsing Error: not well-formed Location: http://www.kernow-connect.com/index_latest_results.xml Line Number 6, Column 19: <release date>2011-08-29</release date> -------------------------^
thanks
Luke
Comment