parse error, unexpected T_OBJECT_OPERATOR

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sky2070

    parse error, unexpected T_OBJECT_OPERATOR

    Parse error: parse error, unexpected T_OBJECT_OPERAT OR, expecting ')'
    in c:\inetpub\wwwr oot\session.php on line 19

    can anyone tell me what is wrong with this code???

    <?
    // Define the Session class
    class Session
    {
    // Define the properties:
    var $sqlhost="local host";
    var $sqluser="root" ;
    var $sqlpass="";
    var $sqldb="ecommer ce";
    var $linkid;
    var $seshid;
    var $sessdata;
    var $err;
    var $err_no;
    var $expire_time=90 0; // length of time until expiration in seconds
    var $userid;

    // Define the methods:
    function Session($this->seshid,$this->userid=0)
    {
    // connect to MySQL
    $this->linkid=mysql_c onnect($this->sqlhost,$thi s->sqluser,$thi s->sqlpass);
    // verify connection made
    if (!$this->linkid) // was not able to connect
    {
    $this->err=mysql_erro r();
    $this->err_no=101;
    return;
    }
    // select database
    $result=mysql_s elect_db($this->sqldb,$this->linkid);
    if (!$result) // unable to select db
    {
    $this->err= mysql_error();
    $this->err_no=102;
    return;
    }
    // check to see if verifying session or creating session
    if(!$this->seshid) // seshid 0 so creating
    {
    $current=time() ;
    $random=$this->userid . $current;
    $this->seshid=md5(ran dom);
    $query="insert into actsessions
    values('$this->seshid','$th is->userid',
    $current)";
    $result=mysql_q uery($query);
    if (!$result)
    {
    $this->err= mysql_error()";
    $this->err=104;
    return;
    }
    // finished session create return to script
    $this->err_no=0;
    return;
    }
    // not new session, verify
    $result=mysql_q uery("SELECT * FROM actsessions
    WHERE seshid='$this-> seshid'");
    if (!$result) // select failed
    {
    $this->err= mysql_error();
    $this->err_no=103;
    return;
    }
    // verify valid data returned
    $numrows=mysql_ num_rows($resul t);
    if (!$numrows) // no rows returned, seshid not valid
    {
    $this->err="Session id not valid";
    $this->err_no=201;
    return;
    }
    //get session data
    $this->sessdata=mysql _fetch_row($res ult);
    $not_expired=$t his->VerifyTime() ;
    if (!$not_expired) // too much time has passed since last access
    {
    $this->err="Session has expired";
    $this->err_no=202;
    return;
    }
    $this->ResetTime(); // reset lastused to current
    $this->CleanUp(); // remove expired sessions
    $this->err_no=0;
    }

    function VerifyTime()
    {
    $current=time() ; // get current UNIX timestamp
    // check if the session has expired
    if ($this->sessdata[lastused]+$this->expire_time<$c urrent)
    {
    return 0;
    }
    return 1;
    }
    function ResetTime()
    {
    $current=time() ; // get current UNIX timestamp
    $query="update actsessions ";
    $query.="set lastused=$curre nt ";
    $query.="where seshid='$this->seshid'";
    $result=mysql_q uery($query);
    }
    function CleanUp()
    {
    $current=time() ;
    $still_valid=$c urrent-900;
    $query="delete from sessions where lastused<$still _valid";
    $result=mysql_q uery($query);
    }

    } // end of class definition
    ?>
  • Ian.H [dS]

    #2
    Re: parse error, unexpected T_OBJECT_OPERAT OR

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Whilst lounging around on 4 Jul 2003 08:20:59 -0700,
    skywalker2070@h otmail.com (sky2070) amazingly managed to produce the
    following with their Etch-A-Sketch:
    [color=blue]
    > Parse error: parse error, unexpected T_OBJECT_OPERAT OR, expecting
    > ')' in c:\inetpub\wwwr oot\session.php on line 19
    >
    > can anyone tell me what is wrong with this code???
    >
    > <?
    > // Define the Session class
    > class Session
    > {
    > // Define the properties:
    > var $sqlhost="local host";
    > var $sqluser="root" ;
    > var $sqlpass="";
    > var $sqldb="ecommer ce";
    > var $linkid;
    > var $seshid;
    > var $sessdata;
    > var $err;
    > var $err_no;
    > var $expire_time=90 0; // length of time until expiration in seconds
    > var $userid;
    >
    > // Define the methods:
    > function Session($this->seshid,$this->userid=0)
    > {[/color]


    The function call doesn't make sense.. as pointed out by PHP ;)

    Do as it suggests..... and give it the ) where it wants it:


    function Session() {


    You can then access $this->seshid and $this->userid form within the
    function as they're part of the same class.


    HTH.



    Regards,

    Ian

    -----BEGIN PGP SIGNATURE-----
    Version: PGP 8.0

    iQA/AwUBPwWeMmfqtj2 51CDhEQKTMwCfYW HjLNZe8QFGHghrs 8UxaHy3rRgAni1V
    WswGetfU7/X60um+EloWJVZt
    =MA/u
    -----END PGP SIGNATURE-----

    --
    Ian.H [Design & Development]
    digiServ Network - Web solutions
    www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
    Programming, Web design, development & hosting.

    Comment

    • Korthrun McBloodlust

      #3
      Re: parse error, unexpected T_OBJECT_OPERAT OR

      sky2070 wrote:
      [color=blue]
      > Parse error: parse error, unexpected T_OBJECT_OPERAT OR, expecting ')'
      > in c:\inetpub\wwwr oot\session.php on line 19
      >
      > can anyone tell me what is wrong with this code???
      >
      > <?
      > // Define the Session class
      > class Session
      > {
      > // Define the properties:
      > var $sqlhost="local host";
      > var $sqluser="root" ;
      > var $sqlpass="";
      > var $sqldb="ecommer ce";
      > var $linkid;
      > var $seshid;
      > var $sessdata;
      > var $err;
      > var $err_no;
      > var $expire_time=90 0; // length of time until expiration in seconds
      > var $userid;
      >
      > // Define the methods:
      > function Session($this->seshid,$this->userid=0)
      > {
      > // connect to MySQL
      > $this->linkid=mysql_c onnect($this->sqlhost,$thi s->sqluser,$thi s->sqlpass);
      > // verify connection made
      > if (!$this->linkid) // was not able to connect
      > {
      > $this->err=mysql_erro r();
      > $this->err_no=101;
      > return;
      > }
      > // select database
      > $result=mysql_s elect_db($this->sqldb,$this->linkid);
      > if (!$result) // unable to select db
      > {
      > $this->err= mysql_error();
      > $this->err_no=102;
      > return;
      > }
      > // check to see if verifying session or creating session
      > if(!$this->seshid) // seshid 0 so creating
      > {
      > $current=time() ;
      > $random=$this->userid . $current;
      > $this->seshid=md5(ran dom);
      > $query="insert into actsessions
      > values('$this->seshid','$th is->userid',
      > $current)";
      > $result=mysql_q uery($query);
      > if (!$result)
      > {
      > $this->err= mysql_error()";
      > $this->err=104;
      > return;
      > }
      > // finished session create return to script
      > $this->err_no=0;
      > return;
      > }
      > // not new session, verify
      > $result=mysql_q uery("SELECT * FROM actsessions
      > WHERE seshid='$this-> seshid'");
      > if (!$result) // select failed
      > {
      > $this->err= mysql_error();
      > $this->err_no=103;
      > return;
      > }
      > // verify valid data returned
      > $numrows=mysql_ num_rows($resul t);
      > if (!$numrows) // no rows returned, seshid not valid
      > {
      > $this->err="Session id not valid";
      > $this->err_no=201;
      > return;
      > }
      > //get session data
      > $this->sessdata=mysql _fetch_row($res ult);
      > $not_expired=$t his->VerifyTime() ;
      > if (!$not_expired) // too much time has passed since last access
      > {
      > $this->err="Session has expired";
      > $this->err_no=202;
      > return;
      > }
      > $this->ResetTime(); // reset lastused to current
      > $this->CleanUp(); // remove expired sessions
      > $this->err_no=0;
      > }
      >
      > function VerifyTime()
      > {
      > $current=time() ; // get current UNIX timestamp
      > // check if the session has expired
      > if ($this->sessdata[lastused]+$this->expire_time<$c urrent)
      > {
      > return 0;
      > }
      > return 1;
      > }
      > function ResetTime()
      > {
      > $current=time() ; // get current UNIX timestamp
      > $query="update actsessions ";
      > $query.="set lastused=$curre nt ";
      > $query.="where seshid='$this->seshid'";
      > $result=mysql_q uery($query);
      > }
      > function CleanUp()
      > {
      > $current=time() ;
      > $still_valid=$c urrent-900;
      > $query="delete from sessions where lastused<$still _valid";
      > $result=mysql_q uery($query);
      > }
      >
      > } // end of class definition
      > ?>[/color]
      I am just amking this up, but it seems like its not liking the =0 part.
      Im pretty cewrtain you cant set values there. Youa re definging the
      funtion, and telling it waht to expect to ahve passed to it. it
      $this->userid needs to be 0 set it within the function.
      Hope thats right.

      Comment

      Working...