gpt4 book ai didi

mysql - SQL 绑定(bind)变量错误

转载 作者:行者123 更新时间:2023-11-29 12:13:59 27 4
gpt4 key购买 nike

我的代码中出现错误。我确信这意味着我的代码的 column=:variable 部分有问题,但我已经检查过它并且看不出有什么问题。

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in F:\...

这是代码(长第一行):

        $stmt = $dbh->prepare("UPDATE item_list SET quantity=:quantity, new_price=:newprice, image_link=:image_link, market_hash_name=:markethashname, last_update='1000-01-01 00:00:00', is_tradable='TEST', old_price=:oldprice WHERE item_name=:itemname AND (image_link IS NULL OR quantity IS NULL OR new_price IS NULL OR market_hash_name IS NULL OR last_update IS NULL OR is_tradable IS NULL OR old_price IS NULL)");
$sql->bindParam(':quantity', $json2->quantity);
$sql->bindParam(':newprice', $json2->lowest_price);
$sql->bindParam('image_link', $image_link_full);
$sql->bindParam(':markethashname', urlencode($mydata->market_hash_name));
$sql->bindParam(':oldprice', $json2->lowest_price);
$stmt->bindValue(':itemname', $mydata->market_name);
$stmt->execute();

编辑:image_link需要是:image_link,仍然遇到相同的错误

编辑2:有很多错误,使用了两个名称$sql和$stmt,使用bindValue而不是bindParam

最佳答案

bindParam 语句中的“image_link”之前缺少冒号“:”。

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

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