未知的内部500错误?! PHP

时间:2013-06-10 23:45:12

标签: php mysqli syntax-error internal-server-error mysqli-multi-query

以下代码有问题。通常当我得到Internal 500 error时,这只意味着我错过了一个“;”或某个地方的“}”/“{”。我编辑的代码如下:

<?php
//Create game account
$mysqli = new mysqli("localhost", "root", "root", "realdb_table_data");

if (mysqli_connect_errno()) {
    echo("Sorry, the server is 'Under Maintainance'");
    exit();
}

$name = $_COOKIE['name'];
$email = $mysqli->real_escape_string($_POST['email']));
$password = $mysqli->real_escape_string($_POST['password']);
$hash = sha1(strtolower($name) . $password);

if($password == null || $password == "" || (strlen($password)) < 4){
    header("Location:thegoods.php?error=7");//Invalid password
} else if($email == null || $email == "" || (strlen($email) <= 6)){
    header("Location:thegoods.php?error=8");//Invalid Email address
} else{
    $result=$mysqli->query("SELECT * FROM userstable WHERE name='$name'");

    /* fetch associative array */
    while ($row = $result->fetch_assoc()) {
        $pass = $row['pass'];
    }

    /* free result set */
    $result->free();

    if($hash != $pass){
        header("Location:thegoods.php?error=6");//Invalid Password Match
    } else {
        $mysqli->query("UPDATE userstable SET email='$email' WHERE name='$name'");
    }
}
$mysqli->close();
?>

1 个答案:

答案 0 :(得分:3)

$email = $mysqli->real_escape_string($_POST['email']));

应该是

$email = $mysqli->real_escape_string($_POST['email']);