netfrugal Posted September 25, 2006 Share Posted September 25, 2006 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.phpThe 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 itemECHO <<<END<item><title>$name</title><link></link><description></description></item>END;}ECHO <<<END</channel></rss>END;?> Quote Link to comment https://forums.phpfreaks.com/topic/22042-how-do-i-create-an-rss-feed-with-php/ Share on other sites More sharing options...
HuggieBear Posted September 25, 2006 Share Posted September 25, 2006 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.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22042-how-do-i-create-an-rss-feed-with-php/#findComment-98616 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.