By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

parse error, unexpected T_OBJECT_OPERATOR

P: n/a
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')'
in c:\inetpub\wwwroot\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="localhost";
var $sqluser="root";
var $sqlpass="";
var $sqldb="ecommerce";
var $linkid;
var $seshid;
var $sessdata;
var $err;
var $err_no;
var $expire_time=900; // 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_connect($this->sqlhost,$this->sqluser,$this->sqlpass);
// verify connection made
if (!$this->linkid) // was not able to connect
{
$this->err=mysql_error();
$this->err_no=101;
return;
}
// select database
$result=mysql_select_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(random);
$query="insert into actsessions
values('$this->seshid','$this->userid',
$current)";
$result=mysql_query($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_query("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($result);
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($result);
$not_expired=$this->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<$current)
{
return 0;
}
return 1;
}
function ResetTime()
{
$current=time(); // get current UNIX timestamp
$query="update actsessions ";
$query.="set lastused=$current ";
$query.="where seshid='$this->seshid'";
$result=mysql_query($query);
}
function CleanUp()
{
$current=time();
$still_valid=$current-900;
$query="delete from sessions where lastused<$still_valid";
$result=mysql_query($query);
}

} // end of class definition
?>
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on 4 Jul 2003 08:20:59 -0700,
sk***********@hotmail.com (sky2070) amazingly managed to produce the
following with their Etch-A-Sketch:
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting
')' in c:\inetpub\wwwroot\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="localhost";
var $sqluser="root";
var $sqlpass="";
var $sqldb="ecommerce";
var $linkid;
var $seshid;
var $sessdata;
var $err;
var $err_no;
var $expire_time=900; // length of time until expiration in seconds
var $userid;

// Define the methods:
function Session($this->seshid,$this->userid=0)
{

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/AwUBPwWeMmfqtj251CDhEQKTMwCfYWHjLNZe8QFGHghrs8UxaH y3rRgAni1V
WswGetfU7/X60um+EloWJVZt
=MA/u
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #2

P: n/a
sky2070 wrote:
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')'
in c:\inetpub\wwwroot\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="localhost";
var $sqluser="root";
var $sqlpass="";
var $sqldb="ecommerce";
var $linkid;
var $seshid;
var $sessdata;
var $err;
var $err_no;
var $expire_time=900; // 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_connect($this->sqlhost,$this->sqluser,$this->sqlpass);
// verify connection made
if (!$this->linkid) // was not able to connect
{
$this->err=mysql_error();
$this->err_no=101;
return;
}
// select database
$result=mysql_select_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(random);
$query="insert into actsessions
values('$this->seshid','$this->userid',
$current)";
$result=mysql_query($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_query("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($result);
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($result);
$not_expired=$this->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<$current)
{
return 0;
}
return 1;
}
function ResetTime()
{
$current=time(); // get current UNIX timestamp
$query="update actsessions ";
$query.="set lastused=$current ";
$query.="where seshid='$this->seshid'";
$result=mysql_query($query);
}
function CleanUp()
{
$current=time();
$still_valid=$current-900;
$query="delete from sessions where lastused<$still_valid";
$result=mysql_query($query);
}

} // end of class definition
?>

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.

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.