tags:

views:

35

answers:

1

I'm getting the following error in a Joomla model file:

unexpected T_VARIABLE, expecting T_FUNCTION in /var/www/html/clientFiles/components/com_arrcard/models/buynow.php on line 13

Here's the beginning of the file, up through line 14:

<?php

defined( '_JEXEC' ) or die( 'Restricted access' );

 jimport('joomla.application.component.model');

class ArrcardModelBuynow extends JModel
{
    public $failedFields = array();
    public $certificateNumber, $emailAddr, $voucherID, $voucherNbr, $userAcctID;

    //check if user is logged in
        $user =& JFactory::getUser();
        $userAcctID = $user->id;

Does anyone know why the getUser line is causing problems? I've used that code in a number of other places with no errors.

+1  A: 

As the error says, this code:

//check if user is logged in
$user =& JFactory::getUser();
$userAcctID = $user->id;

must be inside a function. Directly in the class, you can only declare member variables. $user doesn't even seem to be defined somewhere.

Felix Kling
Doh! I'm still new to the whole OO thing. Putting it inside a function did indeed fix it.
EmmyS