解析错误:语法错误,第48行/home/a4673434/public_html/index.php中的意外$ end结束

时间:2013-11-16 17:43:40

标签: php mysql

<?php
$mysql_host = "*****.000webhost.com"; // Host masked
$mysql_database = "a4673434_main";
$mysql_user = "a4673434_main";
$mysql_password = "*****"; // password masked
$con = mysqli_connect($mysql_host,$mysql_user,$mysql_password,$mysql_database) or die("Error " . mysqli_error($link));
$email = $_POST["email"];
$confirmemail = $_POST["email2"];
$firstname = $_POST["firstname"];
$surname = $_POST["surname"];
$middlename = $_POST["middlename"];
$password = sha1($_POST["password"]);
$confirmpassword = sha1($_POST["password2"]);
$gender = $_POST["gender"];
$ip = $_SERVER["REMOTE_ADDR"];
$search_num = mysqli_query($con,"SELECT * FROM People WHERE email='$email'");
if(isset($email)) {
if($password!=$confirmpassword) {
echo "Your confirmation password doesn't match your main one!";
}
elseif($email!=$confirmemail) {
echo "Your confirmation email doesn't match your main one!";
}
elseif(mysqli_num_rows($search_num)!=0) {
echo "That email has been taken!";
}
else {
echo "Thanks for signing up!";
$sql = "INSERT INTO People (`firstname`,`lastname`, `email`, `gender`, `ip`, `lastip`, `password`, `middlename`) VALUES ('$firstname', '$surname', '$email', '$gender', '$ip', '$ip', '$password', '$middlename')";
}
?>
<form method="post" action="index.php">
First Name <input type="text" name="firstname" placeholder="First Name" required><br>
Middle Name <input type="text" name="middlename" placeholder="Middle Name" required><br>
Last Name <input type="text" name="surname" placeholder="Last Name" required><br>
Email <input type="email" name="email" placeholder="Email Address" required><br>
Confirm Email <input type="email" name="email2" placeholder="Confirmation Email Address" required><br>
Password <input type="password" name="password" placeholder="Password" required><br>
Confirm Password <input type="password" name="password2" placeholder="Confirmation Password" required><br>
Gender <select required name="gender">
<option selected value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select><br>
<input type="reset" value="Start Over">
<input type="submit" value="Register">
</form>

我该如何解决此错误?这让我烦恼。

  

解析错误:语法错误,意外的$ end in   第48行/home/a4673434/public_html/index.php

我没有在任何地方定义变量$end。这个错误毫无意义。

2 个答案:

答案 0 :(得分:4)

您忘记关闭 isset()

的大括号

像这样添加

    else {
        echo "Thanks for signing up!";
        $sql = "INSERT INTO People (`firstname`,`lastname`, `email`, `gender`, `ip`, `lastip`, `password`, `middlename`) VALUES ('$firstname', '$surname', '$email', '$gender', '$ip', '$ip', '$password', '$middlename')";
    }
} // <-----------Add it here
    ?>

答案 1 :(得分:2)

行“if(isset($ email)){”有一个支撑开始,但你永远不会结束它。因此,PHP解析器会一直尝试直到文件末尾才能找到结束符号。将它添加到你应该拥有它的地方,一切都应该开始工作。