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