tags:

views:

158

answers:

2

Hi, I'm really confused as to why this is kicking up an error?

$admin = substr($_SERVER['REQUEST_URI'], 0, 7);
$account = substr($_SERVER['REQUEST_URI'], 0, 9);
if($admin != '/admin/' || $account != '/account/')
{
}

It is giving this error Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' Why is it doing this?

Thanks Tom

A: 

Is this the only code in the stack??? Are you in the process of switch form php4 to php5? I know alot of times the reason for this is because you are expecting to be using the php5 interpreter and you are actually using a php4 one. Especially if this is being run from the CLI instead of the web or vice versa.

prodigitalson
I can't see though how above code would not work in PHP 4. (I tested it in 5 and it works.)
Pekka
generally its not that specific code it something else where in the stack. That code as he posted it should work in either.
prodigitalson
A: 

This is typically an error from when there is a missing semi colon on the line above, where, for example it will read $admin as a string variable where the line before you were doing a mysql query. Paste some above code for us so we can double check the issue.

[If the problem has already been resolved, apologies, I got sidetracked before answering]

Nathan