...

View Full Version : syntax error, unexpected '&&' ??????



john6
10-24-2012, 05:21 AM
What's wrong with this..


if (isset($_SESSION['var1'])) && (isset($_SESSION['var2'])) && (isset($_GET['var3'])){

?? looks fine to me..

Fou-Lu
10-24-2012, 06:27 AM
Nope, the brackets are incorrect:


if (isset($_SESSION['var1'])) && (isset($_SESSION['var2'])) && (isset($_GET['var3'])){
^

That indicates you are no longer in the if, so you need either an open brace or an expression.
What you want is:


if (isset($_SESSION['var1']) && isset($_SESSION['var2']) && isset($_GET['var3'])){

Or even easier:


if (isset($_SESSION['var1'], $_SESSION['var2'], $_GET['var3']))
{

There the combination indicates all of these need to be set (so same as &&, but cannot be used with || logic).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum