ajcarr1989 Posted November 25, 2010 Share Posted November 25, 2010 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? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 26, 2010 Share Posted November 26, 2010 post the xml output. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 26, 2010 Share Posted November 26, 2010 Query couldn't be executed There's your hint, right there. Quote Link to comment Share on other sites More sharing options...
JakeTheSnake3.0 Posted November 30, 2010 Share Posted November 30, 2010 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) Quote Link to comment 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.