Jump to content

RSS Feed - Does not like arguments after extension in links (eg. index.php?a=1)


Raider

Recommended Posts

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 :)

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.