Jump to content

[SOLVED] Parse error: syntax error, unexpected T_VARIABLE in *******.php


Chris12345

Recommended Posts

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!

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

 

 

 

 

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)?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.