Search code examples
phpsyntax-errorparse-error

Parse error: syntax error, unexpected '}' but can not find another


Ok so I created a form that has one field but multiple submit buttons. Have the form correct, no problem there. Have an issue writing the php code to perform an action depending on which button is pressed. Keep getting a parse and syntax error. I have tried different variations of using the if/else statements as well as isset. Still no luck. AND I don't see any extra } that Im aware of.

    <?php
if($_REQUEST['Gift'] == "Dish1")
{
  header("Location: url1".urlencode($_POST['uid']))
}

else if($_REQUEST['Gift'] == "Dish2")
{
  header("Location: url2".urlencode($_POST['uid']))
}

else if($_REQUEST['Gift'] == "Dish3")
{
  header("Location: url3".urlencode($_POST['uid']))

}

.....etc ?>

It says the error is online 5.... not sure how they parse their lines as the actual url addresses are quite long themselves and none contain }


Solution

  • You are missing a ; at the end of your header statements.

    The } is not expected because a ; (or something else allowed there) is required first.