السلام عليكم
اذاكر لغة البى اتش ابى منذ فترة بسيطة
وعند كتابة الكود التالى فإن محرر اللغة يعطينى الخطأ التالى :
Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ')' in F:\Program Files\EasyPHP 3.0\www\19-4-2009.php on line 19
والمثال هو من كتاب
Professional PHP Prgramming
فصل
Object Oriented Programming
والكود الذى يحتوى على الخطأ هو كالتالى (منذ بداية الاتصال بقاعدة البيانات) :-
ومحرر اللغة يعطى خطأ بداية من Function Session
// Define the Session class
class Session
{
// Define the properties:
var $sqlhost="localhost";
var $sqluser="phpexample";
var $sqlpass="opensource";
var $sqldb="sessions";
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:
} // end of class definition
// 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;
}
// rest of the class definition
} // end of class definition
?>
<?
هل تكرمتم يا اخوتى الكرام بشرح الخطأ وتصحيحه فى هذا المثال
ودمتم موفقين
