Hi there everyone. Does anyone have any idea how to stop my xml feed displaying # instead of £ and companys instead of company's.
I've tried everything I can think of. In UTF-8 it won't show hardly anything in ASCII it works but still spits out the errors above.
<!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=ASCII" http-equiv="Content-Type" />
<title>RAD Feed</title>
</head>
<body>
<?php
include "development/StripAttributes.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 expiry, position, postdate, jobref, salary, jobid, subcounty, country, description FROM jobs");
function stripchars($str)
{
$row = htmlentities("$str");
$row = ereg_replace(128, "€", $row); // Euro symbol
$row = ereg_replace(133, "…", $row); // ellipses
$row = ereg_replace(" ", " ", $row); // space
$row = ereg_replace("&", "&", $row); // and "&", "&",
$row = ereg_replace(8226, "″", $row); // double prime
$row = ereg_replace(8216, "'", $row); // left single quote
$row = ereg_replace(145, "'", $row); // left single quote
$row = ereg_replace(8217, "'", $row); // right single quote
$row = ereg_replace(146, "'", $row); // right single quote
$row = ereg_replace(8220, """, $row); // left double quote
$row = ereg_replace(147, """, $row); // left double quote
$row = ereg_replace(8221, """, $row); // right double quote
$row = ereg_replace(148, """, $row); // right double quote
$row = ereg_replace(8226, "•", $row); // bullet
$row = ereg_replace(149, "•", $row); // bullet
$row = ereg_replace(8211, "–", $row); // en dash
$row = ereg_replace(150, "–", $row); // en dash
$row = ereg_replace(8212, "—", $row); // em dash
$row = ereg_replace(151, "—", $row); // em dash
$row = ereg_replace(8482, "™", $row); // trademark
$row = ereg_replace(153, "™", $row); // trademark
$row = ereg_replace(169, "©", $row); // copyright mark
$row = ereg_replace(174, "®", $row); // registration mark
$row = ereg_replace("","’",$row);//fix SQL
$final = htmlentities("$row");
return $final;
}
// if the file exists already, delete it first to flush data
$xmlfeedfile = "rad.xml";
$filehandle = fopen($xmlfeedfile, 'w');
$itemLink = $fullurl.'/info_jobid_'. $b[jobid].'.html';
$xmlString = '<'.'?'.'xml version="1.0" encoding="ASCII" '.'?' .'>
<source>
<publisher>EditorialJobs.co.uk</publisher>
<publisherurl>http://www.EditorialJobs.co.uk</publisherurl>';
fwrite($filehandle, $xmlString);
while ($row = mysql_fetch_assoc($result)) {
if(strtotime($row['expiry']) < time()) {
continue;
}
$pos = stripslashes(strip_tags($row['position']));
$date = stripslashes(strip_tags($row['postdate']));
$ref = stripslashes(strip_tags($row['jobref']));
$desc = stripslashes(strip_tags($row['description']));
$cnt = stripslashes(strip_tags($row['country']));
$sal = stripslashes(strip_tags($row['salary']));
$loc = stripslashes(strip_tags($row['subcounty']));
$jid = stripslashes($row['jobid']);
$desc = preg_replace('/ /', ' ', $desc);
$desc = preg_replace('/&/', '/&/', $desc);
$desc = preg_replace('/'/', "'", $desc);
$desc = preg_replace('/#/', '£', $desc);
$pos = preg_replace('/ /', ' ', $pos);
$pos = preg_replace('/&/', '/&/', $pos);
$sal = preg_replace('/ /', ' ', $sal);
$sal = preg_replace('/&/', '/&/', $sal);
$sal = preg_replace('/£/', '£', $sal);
$xmlString = "<job>\n\t<title><![CDATA[{$pos}]]></title>\n\t<date><![CDATA[{$date}]]></date>\n\t<referencenumber><![CDATA[{$ref}]]></referencenumber>\n\t<salary>{$sal}</salary>\n\t<url><![CDATA[http://www.editorialjobs.co.uk/info_jobid_{$jid}.html]]></url>\n\t<city><![CDATA[{$loc}]]></city>\n\t<country><![CDATA[{$cnt}]]></country>\n\t<description><![CDATA[{$desc}]]></description>\n</job>";
fwrite($filehandle, $xmlString);
}
mysql_close($dbh);
fwrite($filehandle, "</source>");
fclose($filehandle);
?>
</body>
</html>