gpt4 book ai didi

php - 字符串未插入表中

转载 作者:行者123 更新时间:2023-11-29 23:00:14 25 4
gpt4 key购买 nike

我在下面附上了我的 php 代码,我有一个问题要问你,为什么当我尝试将新用户插入表中时查询不执行?我提到我得到了 succes_set,这意味着 insert_stmt->execute() 运行正确。

if($_SESSION["err_set"] == 0)
{
$password = hash('whirlpool', $password);
$password = strtoupper($password);
$created = date('Y-m-d H:i:s');
// Insert the new user into the database
if($insert_stmt == $db_link->prepare("INSERT INTO users (first_name, last_name, username, email, password, created) VALUES (?, ?, ?, ?, ?, ?)"))
{
$insert_stmt->bind_param('ssssss', $first_name, $last_name, $username, $email, $password, $created);
if (!$insert_stmt->execute())
{
$_SESSION["err_set"] = 1;
$_SESSION["err_txt"] = "Unknown error, code: 1301";
header('Location: ../index.php?page=register&lang='.$language);
}
}
$_SESSION["succes_set"] = 1;
header('Location: ../index.php?page=login&lang='.$language);
}

最佳答案

我解决了这个问题,我删除了其中一个“=”字符

$insert_stmt == $db_link->prepare("INSERT INTO users (first_name, last_name, username, email, password, created) VALUES (?, ?, ?, ?, ?, ?)")

现在我有了

$insert_stmt = $db_link->prepare("INSERT INTO users (first_name, last_name, username, email, password, created) VALUES (?, ?, ?, ?, ?, ?)")

谢谢你们,伙计们。

关于php - 字符串未插入表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28526600/

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