Page 1 of 1

Dynamic RSS Feed Help XML/PHP

Posted: Wed Sep 09, 2009 2:26 am
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>';
?>

Re: Dynamic RSS Feed Help XML/PHP

Posted: Wed Sep 09, 2009 5:10 am
by requinix
Try application/xml instead of text/xml as the Content-Type.

Re: Dynamic RSS Feed Help XML/PHP

Posted: Wed Sep 09, 2009 5:30 am
by techkid
Doesn't work, I mean no change