gpt4 book ai didi

php - 绑定(bind)变量错误

转载 作者:行者123 更新时间:2023-11-30 22:39:29 25 4
gpt4 key购买 nike

我在编写的准备好的语句中遇到错误...

 Number of elements in type definition string doesn't match number of bind variables on line 33. Create Topic Insert bind_param() failed:

我唯一能想到的是因为 NOW() 字段,但我认为不需要为此设置变量?

我是否明显遗漏了什么或者是什么导致了这个错误?

//Prepared INSERT stmt for the forum topic
$stmt = $con->prepare("INSERT INTO forum_topics (`category_id`, `topic_title`, `topic_creator`, `topic_date`, `topic_reply_date`)
VALUES(?, ?, ?, NOW(), NOW())");
if ( !$stmt || $con->error ) {
die('Create Topic Insert prepare() failed: ' . htmlspecialchars($con->error));
}
if(!$stmt->bind_param('sssii', $cid, $title, $creator)) {
die('Create Topic Insert bind_param() failed: ' . htmlspecialchars($stmt->error));
}
if(!$stmt->execute()) {
die('Create Topic Insert execute() failed: ' . htmlspecialchars($stmt->error));
}

最佳答案

mysqli_stmt::bind_param -- mysqli_stmt_bind_param — Binds variables to a prepared statement as parameters

因此在您的 bind_param 中,您需要插入 5 个参数。

关于php - 绑定(bind)变量错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31508374/

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