Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question syntax error, unexpected '&&' ??????

    What's wrong with this..

    PHP Code:
    if (isset($_SESSION['var1'])) && (isset($_SESSION['var2'])) && (isset($_GET['var3'])){ 
    ?? looks fine to me..

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Nope, the brackets are incorrect:
    PHP Code:
    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:
    PHP Code:
     if (isset($_SESSION['var1']) && isset($_SESSION['var2']) && isset($_GET['var3'])){ 
    Or even easier:
    PHP Code:
    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).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •