问题
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 }
回答1:
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.
回答2:
You don't have semicolons. Every statement in PHP must have ';' at the end.
回答3:
You need to pop ;
after statements:
header("Location: url1".urlencode($_POST['uid']));
来源:https://stackoverflow.com/questions/12261161/parse-error-syntax-error-unexpected-but-can-not-find-another