Hi there.
I'm using the following code to create the RSS feed on my site (please note I've edited it in places). My RSS feed is valid however it crashes when I put in pound symbols (£) or dollar symbols ($) or, indeed, any special character (ie: such as a %)
How do I get my PHP-powered RSS feed to work around the special characters problem?
I appreciate any help you can give on this subject.
Here is the code;
Code:<?php $pubDate = date("r"); $year = date("Y"); function iso_8601 ($txt_date) { $fDate = strtotime($txt_date); $main_date = date("Y-m-d\TH:i:s", $fDate); $tz = date("O", $timestamp); $tz = substr_replace ($tz, ':', 3, 0); $return = $main_date . $tz; return $return; } // end function header ("Content-type: text/xml"); echo ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); ?> <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:hr="http://www.w3.org/2000/08/w3c-synd/#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"> <channel rdf:about="http://www.somesite.com/index.php"> <title>TITLE</title> <description>DESCRIPTION</description> <link>LINK</link> <language>en-gb</language> <?php echo ("<pubDate>$pubDate</pubDate>"); echo ("<copyright>Copyright $year. somesite.com</copyright>"); echo ("<webMaster>EMAIL_ADDRESS</webMaster>"); ?> </channel> <?php while ($row = mysql_fetch_array ($result)) { $postid = $row['post_id']; $txt_date = $row['post_date']; $txt_title = $row['post_headline']; $txt_article = $row['post_article']; $txt_title = stripslashes($txt_title); $txt_title = fixDisplay($txt_title); $txt_article = fixDisplay($txt_article); $txt_article = strip_tags($txt_article); $formatted = iso_8601($txt_date); $articleLink = 'http://www.somesite.com/archives'.'/'.$postid; // DO RSS DISPLAY echo ("<item rdf:about=\"http://www.somesite.com\"> <title>"); echo $txt_title; echo ("</title> <description>"); echo $txt_article; echo ("</description> <link>"); echo $articleLink; echo ("</link> <dc:date>"); echo $formatted; echo ("</dc:date> </item>\n\n"); } mysql_free_result ($result); ?></rdf:RDF> mysql_close($connection); ?>





[mmj] My magic jigsaw
.
Bookmarks