2

hello I am getting this error

Parse error: syntax error, unexpected T_VARIABLE in F:\xampp\htdocs\jim\home.php on line 6

$ses_id = session_id();
$user =$_SESSION['user'] 
$sesssion_id=$_SESSION['sessionid'] 
if($user == "" || $sesssion_id != $ses_id)
{
    echo "go back";
}

can anyone tell me what exactly this error mean ? and please see where i am doing wrong

Kamehameha
  • 5,423
  • 1
  • 23
  • 28
Mirza Sahaib
  • 137
  • 1
  • 2
  • 11
  • 1
    add two `;` semi-colons in this two statements ...`$user =$_SESSION['user'] $sesssion_id=$_SESSION['sessionid']` – Tun Zarni Kyaw Mar 16 '14 at 20:04
  • if you are just looking what `T_VARIABLE` means ... view this one http://stackoverflow.com/questions/7640419/why-the-t-in-phps-unexpected-t-variable – Tun Zarni Kyaw Mar 16 '14 at 20:09

3 Answers3

3

Unexpected T_VARIABLE usally means that php was parsing your code, but something unexpected came up as the next characters.

So when parsing your code

$user = $_SESSION['user'] $sesssion_id = $_SESSION['sessionid']

The php parser will get past "$user = $_SESSION['user']", but it expects the assignment to finish with another semi-colon. Without the semi-color it is expecting another assigntment like concatenation or math, however it runs into another assignment and will throw the Unexpected T_VARIABLE.

$sesssion_id = $_SESSION['sessionid'] This is your next block of code, and as everyone else has suggested, the way of fixing the parsing error (the unexcepted T_VARIABLE) is to add a semicolon ( ; ) to let the parser know to start parsing another statement.

Gauthier
  • 1,251
  • 10
  • 25
2

The following is wrong

$ses_id = session_id(); $user =$_SESSION['user'] $sesssion_id=$_SESSION['sessionid']

You need to add ; to end the statement as

$ses_id = session_id(); 
$user =$_SESSION['user'];
 $sesssion_id=$_SESSION['sessionid'];
Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63
0

You've missed ;

  $ses_id = session_id(); 
  $user =$_SESSION['user'] ;
  $sesssion_id=$_SESSION['sessionid'];

  if($user == "" || $sesssion_id != $ses_id){
     echo "go back";
  }
falinsky
  • 7,229
  • 3
  • 32
  • 56