views:

25

answers:

4

Hey,

I have a client who needs a website urgently, but I have no access to information such as the control panel.

PHP Version is 4.4 Which is a pain as I'm used to 5.

The first problem is I keep getting:

Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')' in D:\hshome\*******\********\includes\functions.php on line 37

This is the function in question:

function read_rss($display=0,$url='') {
    $doc = new DOMDocument();
    $doc->load($url);
    $itemArr = array();

    foreach ($doc->getElementsByTagName('item') as $node) {
        if ($display == 0) {
            break;
        }

        $itemRSS = array(
            'title'=>$node->getElementsByTagName('title')->item(0)->nodeValue,
            'description'=>$node->getElementsByTagName('description')->item(0)->nodeValue,
            'link'=>$node->getElementsByTagName('link')->item(0)->nodeValue);

         array_push($itemArr, $itemRSS);

        $display--;
    }
    return $itemArr;
}

And the line in question:

'title'=>$node->getElementsByTagName('title')->item(0)->nodeValue,
A: 

You can't do that in PHP 4.

Have to do something like

   $nodes = $node->getElementsByTagName('title');
   $item = $nodes->item(0);
   $value = $item->nodeValue,

Try it and it will work.

hopeseekr
+2  A: 

PHP4 does not support object dereferencing. So $obj->something()->something will not work. You need to do $tmp = $obj->something(); $tmp->something...

ircmaxell
A: 

You can't chain object calls in PHP 4. You're going to have to make each call separately to a variable and store it all.

$titleobj = $node->getElementsByTagName('title');
$itemobj = $titleobj->item(0);
$value = $itemobj->nodeValue;

...

'title'=>$value,

you'll have to do it on all those chained calls

As for .htaccess ... you need to talk to someone who controls the actual server. It sounds like .htaccess isn't allowed to change the setting you're trying to change.

Cfreak
A: 

You need to break down that line into individual variables. PHP 4 does not like -> following parentheses. Do this instead:

    $title = $node->getElementsByTagName('title');
    $title = $title->item(0);
    $description = $node->getElementsByTagName('description');
    $description = $description->item(0);
    $link = $node->getElementsByTagName('link');
    $link = $link->item(0);

    $itemRSS = array(
        'title'=>$title->nodeValue,
        'description'=>$description->nodeValue,
        'link'=>$link->nodeValue);

The two variable declarations for each may be redundant and condensed, I'm not sure how PHP4 will respond. You can try to condense them if you want.

js1568