简体   繁体   English

PHP SQL插入准备好的语句无法正确插入

[英]PHP SQL insert prepared statements doesn't insert properly

When executing the following code, no Errors occur but the data isn't put into the database! 执行以下代码时,不会发生任何错误,但是数据不会放入数据库中!

$zero = 0;
    $connection = new mysqli("localhost", "andrewle_me", "*****", "andrewle_velocity");
    $stmt = $connection->prepare("INSERT INTO accounts Values(?, ?, ?, ?, ?, ?, ?, ?)");
    $stmt->bind_param("issssssi", $zero, $_POST["username"], password_hash($_POST["password"], PASSWORD_DEFAULT), $_POST["Email"], $_POST["firstname"], $_POST["lastname"], $_POST["nationality"], $zero);
    $stmt->execute();
    $stmt->close();
    $connection->close();
    echo "Success";

Define your posts and password hash outside of the param binding. 在参数绑定之外定义您的帖子和密码哈希。 Set the fields in the table that your values are going to be entered into. 在要输入值的表中设置字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM