Chris12345 Posted March 23, 2009 Share Posted March 23, 2009 Hello, I am having trouble with this code, I have checked it many times and I cant seem to find the problem please help! The basic idea of this script is to give me easy access to update my RSS feed using PHP. The PHP script reads the current RSS feed, explodes it, adds another item and then implodes it. I don't know an easier way to do the RSS updating but any advice would be much appreciated. The error I get is Parse error: syntax error, unexpected T_VARIABLE in /*/*/*/post.php on line 73 And the code is <?php $myFile = "/*/*/*/*/*/news.rss"; $fh = fopen($myFile, 'r'); $currentrss = fread($fh, filesize($myFile)); fclose($fh); $pubDate = date('D, j M Y G:i:s'); $pubDate = $pubDate." GMT"; $section = explode('</language>', $currentrss); // THIS IS LINE 73 $beginning = $section[0]; $beginning = $beginning."</language>"; $end = $section[1]; $middle = "<item> <title>".$_POST['title']."</title> <pubDate>".$pubDate."</pubDate> <description>".$_POST['article']."</description> </item>"; $array = array($beginning, $middle, $end); $newrss = implode("", $array); $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $newrss); fclose($fh); echo "Thanks, your post has now been added to the RSS feed."; ?> Please help! Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/ Share on other sites More sharing options...
trq Posted March 23, 2009 Share Posted March 23, 2009 Doesn't look like 73 lines of code to me? Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/#findComment-791397 Share on other sites More sharing options...
trq Posted March 23, 2009 Share Posted March 23, 2009 Hmmm, ignore that. Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/#findComment-791399 Share on other sites More sharing options...
Chris12345 Posted March 23, 2009 Author Share Posted March 23, 2009 Yeah, sorry, the code above and below the code I posted is HTML so I didn't think that would be necessary to post, but I can if it helps. Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/#findComment-791401 Share on other sites More sharing options...
Chris12345 Posted March 23, 2009 Author Share Posted March 23, 2009 Does anyone know anything that will help me out or an easier way to write an item to an RSS feed? Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/#findComment-791571 Share on other sites More sharing options...
lonewolf217 Posted March 23, 2009 Share Posted March 23, 2009 nevermind again Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/#findComment-791667 Share on other sites More sharing options...
shadiadiph Posted March 23, 2009 Share Posted March 23, 2009 looks like line 73 is line 73 on the rss feed not on the post.php well this doesn't look right an xhtml </language> how can you explode that? once you have opened the rss print it so you can keep track of what you are looking at. i am scepitcal that the file you opened is in the same xhtml format it started in Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/#findComment-791669 Share on other sites More sharing options...
Chris12345 Posted March 23, 2009 Author Share Posted March 23, 2009 Thanks for your advice. I'm going to try that now. Please correct me if I'm wrong but if the rss feed has this line "<language>en-us</language>" and the contents of the RSS file are in $currentrss then if I explode the </language> then won't that split the $currentrss into 2 parts (before the </language> tag and after)? Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/#findComment-791699 Share on other sites More sharing options...
shadiadiph Posted March 23, 2009 Share Posted March 23, 2009 but you appear to be opening and reading the output will probably look different why dont you include or require the rss file Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/#findComment-791713 Share on other sites More sharing options...
Chris12345 Posted March 23, 2009 Author Share Posted March 23, 2009 Now that is strange. I've just looked at my post.php file in a different PHP editor and strange symbols appeared instead of spaces on that one line. Now I've edited it with a different editor it appears to be working. I'm going to keep this topic open until I have the chance to test it fully. I would like to thank you for taking the time to read through my problem and I'm sorry for wasting your time. Link to comment https://forums.phpfreaks.com/topic/150643-solved-parse-error-syntax-error-unexpected-t_variable-in-php/#findComment-791722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.