Connecting Tech Pros Worldwide Forums | Help | Site Map

error T_OBJECT_OPERATOR

Newbie
 
Join Date: Mar 2008
Posts: 1
#1: Mar 27 '08
Hello dear members,
I am displaying the online news through rss feed in my portal, it is working good enough on localhost WAMP but when i upload the script on our USA based Linux Server I m having the error as below,

T_OBJECT_OPERATOR ,

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/stocksli/public_html/getrss.php on line 23

on the line :
$channel = $xmlDoc->getElementsByTagName('channel')->item(0);

The whole script is as below.

<?php
//get the q parameter from URL
//$q=$_GET["q"];

//find out which feed was selected
/*if($q=="Google")
{
$xml=("http://news.google.com/news?ned=us&topic=h&output=rss");
}
elseif($q=="MSNBC")
{
$xml=("http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml");
}
*/

//$xml=("http://moneycontrol.com/rss/business.xml");

$xml=("http://moneycontrol.com/rss/business.xml");
$xmlDoc = new DOMDocument() or die("Oops Object Not Created");;
$xmlDoc->load($xml) or die("Problem Downloading The XML file");;

//get elements from "<channel>"
$channel = $xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
$channel_desc = $channel->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;

//output elements from "<channel>"
echo("<p align='center'><font size='-20'><a href='" . $channel_link . "'>" . $channel_title . "</a>");
echo("<br />");
echo($channel_desc . "</font></p>");

//get and output "<item>" elements
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<=4; $i++)
{
$item_title=$x->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
$item_link=$x->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
$item_desc=$x->item($i)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;

echo ("<p><a href='" . $item_link . "'>" . $item_title . "</a>");
echo ("<br />");
echo ($item_desc . "</p>");
}
//echo "<p align='right'><a href='" . $channel_link . "'>more news ....</a></p>";

?>

PLEASE GIVE ME SOLUTION IF KNOWN.
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Mar 27 '08

re: error T_OBJECT_OPERATOR


When using this forum, use the code=xxx tags [you can read about them in the forum guidelines].

What PHP version does your live server use?
Reply