Raider Posted December 8, 2009 Share Posted December 8, 2009 Hi there. I'm trying to make an RSS feed for my website (a blog), but it seems harder than I anticipated. Right now, what I'm doing is executing a script once in a while which writes a full RSS feed (with updated articles and whatnot) to a file, rss.xml. All seems to be working correctly, except for one thing. When I use the <link></link> tags, I link to a page which looks like: index.php?a=001&aid=15. That is, it has arguments at the end. I've tried validating my RSS feed but it doesn't like the last bit (if I just use index.php for every link, no errors pop up). Any ideas on how I can fix this problem? Thanks Link to comment https://forums.phpfreaks.com/topic/184453-rss-feed-does-not-like-arguments-after-extension-in-links-eg-indexphpa1/ Share on other sites More sharing options...
jonsjava Posted December 8, 2009 Share Posted December 8, 2009 When I wrote the RSS script for my wife's website, I didn't run into that problem. If you would like to see how someone else came at the RSS issue, you can go over my code: <?php header("Content-type:application/rss+xml"); echo <<<END <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>zyxyeLLowxyz</title> <description>The collections of the inner workings of yeLLow</description> <link>http://zyxyellowxyz.com/</link> <copyright>copyright 2007-2009 S.L. Harris</copyright> END; include("db.inc.php"); $sql = "***************************"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)){ $id = $row['id2']; $url = "http://zyxyellowxyz.com?post=$id"; $title = htmlentities(strip_tags($row['title'])); $message = htmlentities(strip_tags($row['message'], 'ENT_QUOTES')); $message_array = explode("\n", $message); $message = ""; foreach ($message_array as $value){ $message .= "<p>$value</p>"; } $date = $row['rfc_date']; echo <<<END <item> <guid>$url</guid> <title> $title</title> <description>$message</description> <link>$url</link> <pubDate> $date</pubDate> </item> <atom:link href="http://zyxyellowxyz.com/rss.php" rel="self" type="application/rss+xml" /> END; } ?> </channel> </rss> If you have any questions as to why I did it this way, just PM me. I'm heading home for the night. Link to comment https://forums.phpfreaks.com/topic/184453-rss-feed-does-not-like-arguments-after-extension-in-links-eg-indexphpa1/#findComment-973819 Share on other sites More sharing options...
thebadbad Posted December 8, 2009 Share Posted December 8, 2009 Encode your ampersands as & Link to comment https://forums.phpfreaks.com/topic/184453-rss-feed-does-not-like-arguments-after-extension-in-links-eg-indexphpa1/#findComment-973821 Share on other sites More sharing options...
Raider Posted December 9, 2009 Author Share Posted December 9, 2009 Hey, thanks for the replies. I tried something similar to what you posted, Jonsjava, but the server I am using doesn't seem to like it. I'm not sure if it's running apache or not, and I don't know how to make it so that it interprets this file as a PHP file, yet has XML extension so that RSS readers don't complain. I added the & and it seems to work Thanks to both. Link to comment https://forums.phpfreaks.com/topic/184453-rss-feed-does-not-like-arguments-after-extension-in-links-eg-indexphpa1/#findComment-974389 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.