Hi Guys!
Im using PHP to generate an XML feed on the fly. All of my data is stored in a MySQL database. From time to time, i’m getting some strange characters show in the XML output, for example:
HR Advisor role – 9m contract – London
Part-time HR Manager Role – Digital Marketing
Here’s a snippet of my PHP script that parses the data from the database and TRIES to get it in a readable format…
foreach($jobs as $key=>$array){
$rss_title = htmlspecialchars($jobs[$key]['job_title']); // Job title
$rss_title = html_entity_decode($rss_title, ENT_COMPAT,'UTF-8');
$rss_description = strip_tags($jobs[$key]['job_description']); // Description
$rss_description = html_entity_decode($rss_description, ENT_COMPAT,'UTF-8');
if(strlen($rss_description) > 400){
$rss_description = substr($rss_description, 0, 400).'...'; // Shorten description
}
$rss_date = $jobs[$key]['date_posted']; // Date posted
$rss_link = SITEURL.'/'.$this->settings['company_directory'].'/'.$jobs[$key]['company_url'].'/'.$jobs[$key]['job_url']; // Link
$date = date("D, d M Y G:i:s", strtotime($rss_date));
$date = $date.' +0000';
$result .= '<item>';
$result .= '<title><![CDATA['.$rss_title.']]></title>';
$result .= '<description><![CDATA['.$rss_description.']]></description>';
$result .= '<link><![CDATA['.$rss_link.']]></link>';
$result .= '<guid>'.$rss_link.'</guid>';
$result .= '<pubDate>'.$date.'</pubDate>';
$result .= '</item>';
}
Any ideas what’s wrong?
Thanks in advance