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 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    47
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Grr...if else problem...

    Alright, I've got this code, but I can't for the life of me figure out what is going wrong. When I run it, it gives me an unexpected '{' error.

    Code:
    if (($_COOKIE["6511102b"]!="newFile") || 
        (empty($_SESSION["gender"]) || 
        (empty($_SESSION["name"])) {
        echo "WHOA WHOA WHOA WHOA. You did something wrong. Or something. Go <a href='newGame.php'>back here</a> to remake your file.</a>";
    } else {
    It's probably some stupid problem, but can you guys help me out?

  • #2
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    Brackets are confusing

    PHP Code:
    if (($_COOKIE["6511102b"]!="newFile") || (empty($_SESSION["gender"])) || (empty($_SESSION["name"]))) {
        echo 
    "WHOA WHOA WHOA WHOA. You did something wrong. Or something. Go <a href='newGame.php'>back here</a> to remake your file.</a>";
    } else { 

  • #3
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,306
    Thanks
    4
    Thanked 205 Times in 202 Posts
    You opened a brace on the else but don't appear to have anything after it nor the closing brace.

    PHP Code:
    } else {
    print 
    'do something';

    Dave .... HostMonster for all of your hosting needs

  • #4
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    I assume he left that off intentionally, but he was missing extra closing parenthesis on line 2 and 3, which I fixed in my post above.

  • #5
    New Coder
    Join Date
    Jun 2008
    Posts
    47
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Thanks - now it works.


  •  

    Posting Permissions

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