【发布时间】:2013-06-12 15:28:41
【问题描述】:
我明白了
警告:PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: 无效参数号:未定义参数
当尝试运行以下代码时,bindValue 和 bindParam 似乎都看不出有什么问题。
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');
【问题讨论】:
-
不知道是不是因为
-。尝试不使用它,例如:productName -
天哪?呃,是的,做到了。谢谢!!!不敢相信。我花了几个小时!!!新鲜的眼睛总是受欢迎的。