472,805 Members | 1,256 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

parse error, unexpected T_OBJECT_OPERATOR

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
2 51316
-----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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marten van Urk | last post by:
I got the following error in my page Parse error: parse error, unexpected T_ELSE in line 25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Club</title>...
6
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After...
8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
5
by: Anna MZ | last post by:
I am new to php and have written the following mysql code to enter the details of a new user in the admin subdomain of my website: $sql = "INSERT INTO 'users' ('userid', 'username', 'upassword')...
1
by: soidariti | last post by:
database error - parse error, unexpected $, expecting kEND AddUserAuthorisationToUsers.rb migration file 1. class AddUserAuthorisationToUsers < ActiveRecord::Migration 2. def self.up ...
1
epots9
by: epots9 | last post by:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/xxx.php on line xxx I get that message when i try to run my...
3
by: nazgul42 | last post by:
I am writing a very simple login script for a website that I am also writing, but when I try to run it, the only error I get is: Parse error: parse error, unexpected $ in...
5
by: devereaux | last post by:
I'm trying to run a script and it's throwing the following error: Parse error: syntax error, unexpected T_OBJECT_OPERATOR in openfile.php on line 41 Here is the openfile.php file and I have...
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.