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

Parse error: syntax error, unexpected T_VARIABLE

P: 2
Hi everyone,

I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the offending line, but being amateur, I don't know where. I've tried putting one in several places, to no avail. Clearly, to solve this in a smaller period than a week I need someone with more skill to help out. Heh heh.

The error is:

Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in C:\xampplite\htdocs\BraysideSite\Pages\blog.php on line 11

The following is the offending section of code. Line 11 is the "if $_SESSION" line.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include("connection.php");
  3. if $_SESSION['curr_user'] == '';
  4. {
  5. //Redirects to login page below
  6. header('Location: blog.php');
  7. }
  8. ?>
  9.  
If anyone could help me with this, it'd be much appreciated.

Thanks,
Silva
Dec 1 '07 #1
Share this Question
Share on Google+
3 Replies


Markus
Expert 5K+
P: 6,050
Hi everyone,

I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the offending line, but being amateur, I don't know where. I've tried putting one in several places, to no avail. Clearly, to solve this in a smaller period than a week I need someone with more skill to help out. Heh heh.

The error is:

Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in C:\xampplite\htdocs\BraysideSite\Pages\blog.php on line 11

The following is the offending section of code. Line 11 is the "if $_SESSION" line.

<?php
include("connection.php");
if $_SESSION['curr_user'] == '';
{
//Redirects to login page below
header('Location: blog.php');
}
?>

If anyone could help me with this, it'd be much appreciated.

Thanks,
Silva
Your IF statement needs to be wrapped in ( )

i.e
Expand|Select|Wrap|Line Numbers
  1. if ($_SESSION['curr_user'] == '')
  2.  
and you also dont want the semi colon at the end :)
Dec 1 '07 #2

P: 2
Ahh. I see. I'll try it out.

It works. Thank you very much for your help.
Dec 2 '07 #3

ak1dnar
Expert 100+
P: 1,584
Please use the [code=xxx] tags provided. You can find it here
posting guidelines
Dec 2 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.