Jump to content

Recommended Posts

I need help here.  I see so many xml rss feeds out there and wonder how they dynamically populate their feeds.

Below is the code I am using from a tutorial I found online. But I still get validation errors that I simply do not understand. I've tested the feed on 3 different readers: Mozilla thunderbird, RssReader 1.0, and FeedReader 2.90.

The tutorial showed me to create the feed with a .php extension.  Are not RSS feeds in XML? 

You can test the feed at marcsteele.com/z.php in a rss reader.
FeedValidator.org gives me the following errors:
http://www.feedvalidator.org/check?...teele.com/z.php

The weird thing is that I can get it to work on my localhost db, but not when I upload it to my server and call data from the production server's db.

I am using IIS for the production server, and apache for my localhost. I can't image why that would make a difference.

The only other issue I can image that is affecting the output is maybe apostrophes or special characters. Any help would be appreciated.

My code:

<?
header("Content-Type: text/xml;charset=utf-8");
$connection = @mysql_connect("localhost", "root", "password");
$db = @mysql_select_db('pl', $connection);
$sql = "SELECT * from products_description";
$result = @mysql_query($sql, $connection);
ECHO <<<END
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Testing Oscommerce RSS Feeds</title>
<link>http://localhost/</link>
<description>Testing out Dynamic RSS feed from mysql.</description>
END;
while($row = mysql_fetch_array($result)) {
$name = $row['products_name'];
// display an item
ECHO <<<END
<item>
<title>$name</title>
<link></link>
<description></description>
</item>
END;
}
ECHO <<<END
</channel>
</rss>
END;
?>
Link to comment
https://forums.phpfreaks.com/topic/22042-how-do-i-create-an-rss-feed-with-php/
Share on other sites

Have you tried correcting the errors generated?

You have formatting in your XML, I don't think that's correct, I think you have to have a seperate stylesheet for formatting.

Try making changes as suggested by feed validator.

1. Remove the [code=php:0]<br>[/code] tag.
2. Get rid of the [code=php:0]<b>[/code] tags.
3. Make sure the SQL actually works first by using something like phpMyAdmin.

Regards
Huggie
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.