Dynamic RSS Feed Help XML/PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
techkid
Forum Commoner
Posts: 54
Joined: Sat Sep 05, 2009 11:18 pm
Location: Maldives

Dynamic RSS Feed Help XML/PHP

Post by techkid »

I programmed a Dynamic RSS Feed Script and saved it as rss.php

But when i open it on browser, Here is what I see:
Image

I want to display it on rss style, How do i do that?

Here is the source

Code: Select all

<?php
header('Content-Type: text/xml');
 
echo '<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
<title>My Website Name</title>
<description>A description of the feed</description>
<link>The URL to the website</link>';
$db_host = 'localhost'; // host name
$db_user = 'root'; // db username
$db_pass = ''; // db user passwod
$db_name = ''; // database
$connection = mysql_connect($db_host, $db_user, $db_pass)or die(mysql_error());
$sel = mysql_select_db($db_name)or die('cant connect to the database');
 
$get_articles = "SELECT `index` , `news` , `title`, DATE_FORMAT(date,'%a, %e %b') as formatted_date FROM `content` ORDER BY `index` DESC LIMIT 10";
 
$articles = mysql_query($get_articles) or die(mysql_error());
 
while ($article = mysql_fetch_array($articles)){
      
    echo '
       <item>
          <title>'.$article[title].'</title>
          <description>', htmlentities(strip_tags(substr(
$article['news'], 0, 100))), '</description>
          <link>http://localhost/tec/blog.php?id='.$article[index].'</link>
          <pubDate>'.$article[formatted_date].'</pubDate>
      </item>';
}
echo '</channel>
</rss>';
?>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Dynamic RSS Feed Help XML/PHP

Post by requinix »

Try application/xml instead of text/xml as the Content-Type.
User avatar
techkid
Forum Commoner
Posts: 54
Joined: Sat Sep 05, 2009 11:18 pm
Location: Maldives

Re: Dynamic RSS Feed Help XML/PHP

Post by techkid »

Doesn't work, I mean no change
Post Reply