scadran Posted April 22, 2007 Share Posted April 22, 2007 guys, here is the simple code i used to create a RSS but this error appears Parse error: syntax error, unexpected T_STRING in C:\wamp\www\Journalness\rss.php on line 11 here is the code: <?php $connection = mysql_connect("localhost", "root", "123"); mysql_select_db("emu", $connection); $select = "SELECT `id`, `title`, `entry_text`, `date` FROM `emu_entries` 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($entry_text); fwrite($file, "<item> <title>$title</title> <link>http://localhost/Journalness/past.php?id=$id</link> <description>$content</description> </item>"); } //end of while loop fwrite($file, "</channel></rss>"); fclose($file); ?> I am sure there s no problem with my database connection and the file previlage. Regards Mohsen Link to comment https://forums.phpfreaks.com/topic/48078-solved-xml-problem/ Share on other sites More sharing options...
V34 Posted April 22, 2007 Share Posted April 22, 2007 <?php fwrite($file, "<?xml version=\"1.0\"?> ?> That should do it. You broke the outer quotation-marks. Link to comment https://forums.phpfreaks.com/topic/48078-solved-xml-problem/#findComment-234967 Share on other sites More sharing options...
scadran Posted April 22, 2007 Author Share Posted April 22, 2007 so how about the rest of the file content which needs to be written in the same file? Shall I open the <?php tag again? any btw it didn't solve the problem... same error occurs! more idea? Link to comment https://forums.phpfreaks.com/topic/48078-solved-xml-problem/#findComment-234968 Share on other sites More sharing options...
V34 Posted April 22, 2007 Share Posted April 22, 2007 Sorry for the misunderstanding with the <?php tags. I don't know why I placed them. <?php $connection = mysql_connect("localhost", "root", "123"); mysql_select_db("emu", $connection); $select = "SELECT `id`, `title`, `entry_text`, `date` FROM `emu_entries` 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($entry_text); fwrite($file, "<item> <title>$title</title> <link>http://localhost/Journalness/past.php?id=$id</link> <description>$content</description> </item>"); } //end of while loop fwrite($file, "</channel></rss>"); fclose($file); ?> I'm pretty sure this will work. Link to comment https://forums.phpfreaks.com/topic/48078-solved-xml-problem/#findComment-234976 Share on other sites More sharing options...
Guest prozente Posted April 22, 2007 Share Posted April 22, 2007 EDIT: nevermind, V34 beat me to it. Link to comment https://forums.phpfreaks.com/topic/48078-solved-xml-problem/#findComment-234977 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.