PHP准备的语句问题

约翰·麦克

慢慢习惯了PHP准备好的语句,但是仍然出现此错误

“警告:mysqli_stmt :: bind_result():绑定变量数与第20行C:\ Users \ PC \ Documents \ XAMPP \ htdocs \ login.php中已准备好的语句中的字段数不匹配”。

 <?php

 $mysqli = new mysqli('localhost', 'c3337015', 'c3337015', 'members');

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
    }

 if(isset($_GET['loginEmail'])){

 session_start();

    $stmt = $mysqli->prepare("SELECT Email FROM members WHERE Email=? AND  Password=? LIMIT 1");
    $email = $_GET['loginEmail'];
    $password = $_GET['loginPassword'];
    $password = sha1($password);
    $stmt->bind_param('ss', $email, $password);
    $stmt->execute();
    $stmt->bind_result($email, $password);
    $stmt->store_result();
    if($stmt->num_rows == 1)  //To check if the row exists
        {
            while($stmt->fetch()) //fetching the contents of the row

              {$_SESSION['Logged'] = 1;
               $_SESSION['Email'] = $email;
               header('Location: index.php');
               exit();
               }
        }
        else {
            echo "Wrong Username or Password!";
        }
        $stmt->close();
    }
    else 
    {   
    echo "Something went Wrong";
    }
$mysqli->close();
?>
火箭危险品
$stmt->bind_result($email, $password);

您要绑定2个变量,但只要求一个:SELECT Email FROM members

我还建议为使用不同的变量bind_result,因为它和bind_param两者都可以在引用上工作。

$stmt->bind_result($userEmail);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章