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, "&euro;", $row); // Euro symbol
    $row = ereg_replace(133, "&#133;", $row); // ellipses
	$row = ereg_replace("&nbsp;", "&#160;", $row); // space
	$row = ereg_replace("&", "&amp;", $row); // and							"&", "&amp;",
	$row = ereg_replace(8226, "&#8243;", $row); // double prime
    $row = ereg_replace(8216, "&#039;", $row); // left single quote
    $row = ereg_replace(145, "&#039;", $row); // left single quote
    $row = ereg_replace(8217, "&#039;", $row); // right single quote
    $row = ereg_replace(146, "&#039;", $row); // right single quote
    $row = ereg_replace(8220, "&#034;", $row); // left double quote
    $row = ereg_replace(147, "&#034;", $row); // left double quote
    $row = ereg_replace(8221, "&#034;", $row); // right double quote
    $row = ereg_replace(148, "&#034;", $row); // right double quote
    $row = ereg_replace(8226, "&#149;", $row); // bullet
    $row = ereg_replace(149, "&#149;", $row); // bullet
    $row = ereg_replace(8211, "&#150;", $row); // en dash
    $row = ereg_replace(150, "&#150;", $row); // en dash
    $row = ereg_replace(8212, "&#151;", $row); // em dash
    $row = ereg_replace(151, "&#151;", $row); // em dash
    $row = ereg_replace(8482, "&#153;", $row); // trademark
    $row = ereg_replace(153, "&#153;", $row); // trademark
    $row = ereg_replace(169, "&copy;", $row); // copyright mark
    $row = ereg_replace(174, "&reg;", $row); // registration mark
    $row = ereg_replace("","&#8217;",$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('/#/', '&#163;', $desc);
$pos = preg_replace('/&nbsp;/', ' ', $pos);
$pos = preg_replace('/&/', '/&amp;/', $pos);
$sal = preg_replace('/&nbsp;/', ' ', $sal);
$sal = preg_replace('/&/', '/&amp;/', $sal);
$sal = preg_replace('/&#163/', '&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>

Recommended Answers

All 6 Replies

Its been done in your script that's why those characters are being replaced.Have a look at line 79 and 80.Apostrophie char and the '£' are been replaced over there.
You can comment those lines, safely changing the input parameters in the next line.

Its been done in your script that's why those characters are being replaced.Have a look at line 79 and 80.Apostrophie char and the '£' are been replaced over there.
You can comment those lines, safely changing the input parameters in the next line.

Its been done in your script that's why those characters are being replaced.Have a look at line 79 and 80.Apostrophie char and the '£' are been replaced over there.
You can comment those lines, safely changing the input parameters in the next line.

If I remove those, they still come up as # and another symbol instead of the '

Is that your complete script or just the part of it?because stripchars function is not being used anywhere.
and commenting them like below, should make it, but if it's not then there's something weired happening.
Please check if you looking at all the relevant code

Is that your complete script or just the part of it>

It's the complete script.

(It displays ok in firefox, the problem is the feed has to display in IE otherwise the company I'm dealing with can't process it)

i know it, one of my project had the same problem with such special characters.there i was dealing with some portugal characters.
echo this two lines after you fetch it from db. and post them here, just check if the "preg_replace" is working fine or there's some other issue.

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.