Jump to content

Dynamic RSS Feed not working..


ajcarr1989

Recommended Posts

Hi,

I have a problem with an RSS Feed. the error im getting on the W3C validator is this:

This feed does not validate.

 

    *

 

      line 1, column 0: XML parsing error: <unknown>:1:0: syntax error [help]

 

          Query couldn't be executed

 

In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendation.

 

    *

 

      "text/xml" media type is not specific enough [help]

 

 

 

.htaccess

AddType application/x-httpd-php .xml

 

rss.php

<?


//Set XML header for browser
header('Content-type: text/xml');

//Create the heading/channel info for RSS Feed
$output = '<rss version=\"2.0\">';
$output .= '<channel>';
$output .= '<title>Muzo Feed</title>';
$output .= '<description>Your RSS Feed Description</description>';
$output .= '<link>http://mi-linux.wlv.ac.uk/~0703272</link>';

//Individual Items of our RSS Feed
//Connect to a database and and display each new item in our feed    

//Connect to DB
$host = "localhost";          //Name of host
$user = "0703272";            //User name for Database
$pass = "rachel123";             //Password for Database
$db = "db0703272";          //Name of Database
mysql_connect($host,$user,$pass);

//Create SQL Query for our RSS feed
$sql = "SELECT `title`, `webaddress`, `message`, `date_added` FROM `messages`ORDER BY `date_added` DESC LIMIT 0 , 15";
$result = mysql_query($sql) or die ("Query couldn't be executed");  

//Create Loop for the individual elements in the RSS item section
while ($row = mysql_fetch_array($result))
{
$output .= '<item>';
$output .= '<title>'.$row['title'].'</title>';
$output .= '<link>http:/mi-linux.wlv.ac.uk/~0703272/blog.php'.$row['link'].'</link>';
$output .= '<message>'.$row['message'].'</description>';
$output .= '<date_added>'.$row['date'].'</pubDate>';
$output .= '</item>';
}

//Close RSS channel
$output .= '</channel>';
$output .= '</rss>';

//Display output in browser
echo $output;
?>

 

any ideas?

Link to comment
Share on other sites

Right there in the script, I see "header('Content-type: text/xml');"...that's what the 2nd 'error' is telling you.  You're explicitly setting the header to be "text/xml" instead of "application/rss+xml" which is the MIME type made specifically for RSS.

 

Now as to the first error, you're missing the 1st xml element...<?xml version="1.0"?>

 

Also, posting exactly what your script produces will help greatly.

 

** On another note, it's usually a good idea to remove or obfuscate your database username and password.

*** The line AddType application/x-httpd-php .xml simply tells your server how to handle .xml files (currently it's being passed to PHP)

Link to comment
Share on other sites

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.