gpt4 book ai didi

php - 无效参数编号 : parameter was not defined - PHP/MYSQL

转载 作者:行者123 更新时间:2023-11-29 01:42:22 24 4
gpt4 key购买 nike

我明白了

Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

当尝试运行以下代码时,同时使用 bindValuebindParam 似乎看不出有什么问题。

class Product {

public function productAdd($x) {
$core = Core::getInstance(); // This part works OK
$stmt = $core->dbh->prepare('INSERT INTO Product (Product_Name) VALUES (:product-name)');
$stmt->bindValue(':product-name', $x, PDO::PARAM_STR);
$stmt->execute();
}

}

$product = new Product;
$productadd = $product->productAdd('Blue Sunglasses');

最佳答案

命名参数必须是以下之一:

BINDCHR     = [:][a-zA-Z0-9_]+;

将连字符更改为下划线或将其删除。

关于php - 无效参数编号 : parameter was not defined - PHP/MYSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17069431/

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