sudsy1970 Posted November 21, 2010 Share Posted November 21, 2010 Hi i have a simple blog which is stored in a table called messages, i have tried to create an rss feed that poeple can link to but am a bit stuck. the feed does not validate with the error code of: Sorry This feed does not validate. line 15, column 2: XML parsing error: <unknown>:15:2: not well-formed (invalid token) [help] $sql = "SELECT title FROM messages ORDER BY date_added DESC limit 0,10"; Anybody got any ideas on this please, have read the rss pages and can comsume a fedd ok just cant produce one. <?php $host = ""; $user = ""; $pass = ""; $port = "3306"; $database = "uni"; $MySQL = mysql_connect( "$host:$port", $user, $pass ); mysql_select_db( $database, $MySQL) or die ( "Couldn't open $database: ".mysql_error() ); ?> // Get latest items from db $sql = "SELECT title FROM messages ORDER BY date_added DESC limit 0,10"; $rst = mysql_query($sql); // Loop through data and build feed items $items = ""; while($a_row = mysql_fetch_assoc($rst)) { $items.= "<item>"; $items.= " <title>{$rst['title']}</title>"; $items.= " <link>{$rst['link']}</link>"; $items.= " <description>{$rst['description']}</description>"; $items.= "</item>"; } // Build feed text $feed = "<?xml version=\"1.0\"?>"; $feed.= "<rss version=\"2.0\">"; $feed.= " <channel>"; $feed.= " <title>My cool feed</title>"; $feed.= " <link>http://mi-linux.wlv.ac.uk/~0274148/AWT/blog/index.php</link>"; $feed.= " <description>A cool feed</description>"; $feed.= " $items"; $feed.= " </channel>"; $feed.= "</rss>"; // Display feed text echo $feed; Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/ Share on other sites More sharing options...
BlueSkyIS Posted November 21, 2010 Share Posted November 21, 2010 have you looked at the XML generated by your code? Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1137579 Share on other sites More sharing options...
sudsy1970 Posted November 21, 2010 Author Share Posted November 21, 2010 as the feed does not work, will there be an output and if so how do i see it ? Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1137687 Share on other sites More sharing options...
Garethp Posted November 22, 2010 Share Posted November 22, 2010 Unless the code you gave us is wrong, you haven't opened the tag after ?> meaning that it's not running any PHP after you select a database Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1137705 Share on other sites More sharing options...
BlueSkyIS Posted November 22, 2010 Share Posted November 22, 2010 as the feed does not work, will there be an output and if so how do i see it ? I assume the file resides on a web server. navigate to the file on the web server using a web browser. Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1137709 Share on other sites More sharing options...
sudsy1970 Posted November 22, 2010 Author Share Posted November 22, 2010 ahh hah, right thanks for that, found it and navigated to it to find XML Parsing Error: not well-formed Location: http://127.0.0.1/bloggy/rss.xml Line Number 15, Column 3: $sql = "SELECT title FROM messages ORDER BY date_added DESC limit 0,10"; --^ Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1137827 Share on other sites More sharing options...
sudsy1970 Posted November 22, 2010 Author Share Posted November 22, 2010 Anyone any ideas on why the sql could be causing this error ? Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1138103 Share on other sites More sharing options...
BlueSkyIS Posted November 22, 2010 Share Posted November 22, 2010 Unless the code you gave us is wrong, you haven't opened the tag after ?> meaning that it's not running any PHP after you select a database there is a ?>, and everything after that is treated as plain text, not PHP code. Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1138113 Share on other sites More sharing options...
sudsy1970 Posted November 23, 2010 Author Share Posted November 23, 2010 sorry should have said, I have already tried that and still get the same error message. When i posted the the code i hadn't realised i had moved the <? tag when fiddling. have also been playing with my link tag when i think should read : $feed.="<link>localhost/bloggy/index.php</link>"; does this look right for the file on a web server ? Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1138301 Share on other sites More sharing options...
sudsy1970 Posted November 24, 2010 Author Share Posted November 24, 2010 ok have struggled on a bit more and now i have the error message XML Parsing Error: XML declaration not well-formed Location: http://127.0.0.1/bloggy/feed.xmlLine Number 3, Column 19: $host = "http://mi-linux.wlv.ac.uk/~0274148"; -----------------^ This is pointing to the colon, i have tried adding a " afterwards as i thought it may view it as a special charaacter but end up with the same error. Can one explain it to me please ? Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1139074 Share on other sites More sharing options...
JakeTheSnake3.0 Posted November 30, 2010 Share Posted November 30, 2010 This seems all over the place; please post the entirety of your php code from top to bottom and please give us a URL we can use. 127.0.0.1 is a home address...we can't access it. Quote Link to comment https://forums.phpfreaks.com/topic/219386-rss-feeds/#findComment-1141183 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.