All I am trying to do is create an XML feed so that I can submit it to a site. However no matter what I do (albeit with my limited size of brain) all I get are errors. It hates pound signs and apostrophes even if I try the only thing I know which is string replaces. Please someone help. I will post this in the PHP section too.

<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>RAD Feed</title>
</head>

<body>

<?php
$username = ""; //Database Username
$password = ""; //Database Password
$hostname = ""; //Database Host
$dbname = ""; //Database (or Catalog in MySQL parlance) name
$dbh = mysql_connect($hostname, $username, $password) or die("Could not connect to database server");
$selected = mysql_select_db($dbname, $dbh) or die("Database not found or problem connecting");
$result = mysql_query("SELECT position, postdate, jobref, jobid, country, description FROM jobs");

// if the file exists already, delete it first to flush data
$xmlfeedfile = "jobfeed.xml";
$filehandle = fopen($xmlfeedfile, 'w');
$itemLink = $fullurl.'/info_jobid_'.$b[jobid].'.html';

$xmlString = '<?xml version="1.0" encoding="utf-8"?>
<source>
<publisher></publisher>
<publisherurl></publisherurl>';
fwrite($filehandle, $xmlString);
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$xmlString = '<job>
<title>' . $row{position} . '</title>
<date>' . $row{postdate} . '</date>
<referencenumber>' . $row{jobref} . '</referencenumber>
<url><a href="http://www.*****.co.uk' . $fullurl . '/info_jobid_' . $row{jobid} . '.html" target="job' . $row{jobid} . '">' . $row{jobref} . '</a></url>
<country>United Kingdom</country>
<description>' . $row{description} . '</description>
</job>
';
fwrite($filehandle, $xmlString);
}
mysql_close($dbh);
fwrite($filehandle, "</source>");
fclose($filehandle);
?>


</body>

</html>

I can't see any # or &s in your code. If you have any in your variables you probably need to guard these variables using ![CDATA[...]]

Hi there, the £ and &'s come directly out of the mysql database and I can't change that because it is uploaded directly via clients.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.