Facte 0 Light Poster

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 thhe 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, "&euro;", $row); // Euro symbol
    $row = ereg_replace(133, "…", $row); // ellipses
	$row = ereg_replace("&nbsp;", " ", $row); // space
	$row = ereg_replace("&", "&amp;", $row); // and							"&", "&amp;",
	$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, "&copy;", $row); // copyright mark
    $row = ereg_replace(174, "&reg;", $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('/&nbsp;/', ' ', $desc);
$desc = preg_replace('/&/', '/&amp;/', $desc);
$desc = preg_replace('/&apos;/', "'", $desc);
$desc = preg_replace('/#/', '£', $desc);
$pos = preg_replace('/&nbsp;/', ' ', $pos);
$pos = preg_replace('/&/', '/&amp;/', $pos);
$sal = preg_replace('/&nbsp;/', ' ', $sal);
$sal = preg_replace('/&/', '/&amp;/', $sal);
$sal = preg_replace('/£/', '&pound;', $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>
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.