gpt4 book ai didi

PHP mySQLi 插入查询未插入最后一个值

转载 作者:行者123 更新时间:2023-11-29 05:23:53 27 4
gpt4 key购买 nike

所以我有这个查询:

    $query = $connection->prepare("INSERT INTO userdata(Username, Name, Department, Access, Password) VALUES ( ? , ? , ? , ? , ? )");
$query->bind_param('sssdi', $accname, $name, $department, $access, $accpass);
$query->execute();
$query->close();

变量是:

    $accname = 'js1234';
$name = 'Joe Smith';
$department = 'New';
$access = '0';
$accpass = md5('joe1234');

mySQL 结构是:

    Column     Type         Null    Default
ID int(11) No
Username varchar(6) Yes NULL
Name varchar(50) Yes NULL
Department varchar(15) Yes NULL
Access int(11) Yes NULL
Password varchar(32) No

但是当我运行 php 代码时,它只将数字 63 插入到数据库的密码列中,而不是完整的 md5 哈希。其他一切都很好。我在 php 查询中缺少什么?

最佳答案

问题是因为您试图将字符串作为整数插入,您需要将密码哈希作为字符串插入

$query->bind_param('sssds', $accname, $name, $department, $access, $accpass);
//^ note the "s" here for string instead of "i" that you used

关于PHP mySQLi 插入查询未插入最后一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22491464/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com