Snatch Posted January 7, 2008 Share Posted January 7, 2008 Hi, i'm trying to create a dynamic RSS feed for my site but i'm getting the following error: Parse error: syntax error, unexpected T_DNUMBER in C:\xampp\htdocs\website\rss.php on line 11 The code i'm using is: <?php $connection = mysql_connect("localhost", "root", ""); mysql_select_db("shaw", $connection); $select = "SELECT * FROM news ORDER BY id DESC LIMIT 5"; $query = mysql_query($select) or die(mysql_error()); $file = fopen("rss.xml", "w"); fwrite($file, "<?xml version="1.0"?> <rss version="2.0"> <channel> <title>The Shadow Fox Feed</title> <link>http://www.shadow-fox.net</link> <description>Feed Description</description> <language>en-us</language>"); while($array = mysql_fetch_array($query)){ extract($array); $content = htmlentities($content); fwrite($file, "<item> <title>$title</title> <link>http://www.shadow-fox.net/index.php?blog=post&id=$id</link> <description>$content</description> </item>"); } //end of while loop fwrite($file, "</channel></rss>"); fclose($file); ?> Can anyone tell me whats going wrong please? Quote Link to comment https://forums.phpfreaks.com/topic/84935-rss-feed/ Share on other sites More sharing options...
roopurt18 Posted January 7, 2008 Share Posted January 7, 2008 Look at line 11: fwrite($file, "<?xml version="1.0"?> You are prematurely closing the string. Quote Link to comment https://forums.phpfreaks.com/topic/84935-rss-feed/#findComment-433057 Share on other sites More sharing options...
Snatch Posted January 7, 2008 Author Share Posted January 7, 2008 Do you mean the ?> I tried taking out the question mark but it still gives the same error. Quote Link to comment https://forums.phpfreaks.com/topic/84935-rss-feed/#findComment-433068 Share on other sites More sharing options...
trq Posted January 7, 2008 Share Posted January 7, 2008 You need to escape the "s At the moment your string is simply <?xml version= the rest is syntax errors. Quote Link to comment https://forums.phpfreaks.com/topic/84935-rss-feed/#findComment-433074 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.