0
好了,這裏是我的代碼...PDO和bindParam問題
public function insert_cover($title, $description, $category_id, $filename)
{
if($this->category_exists($category_id)) {
$sth = $this->con->prepare('
INSERT INTO cover
(id, title, description, image, category_id, timestamp)
VALUES
(null, :title, :description, :image, :category_id, null)
');
$sth->bindParam(':title', $title, PDO::PARAM_STR);
$sth->bindParam(':description', $description, PDO::PARAM_STR);
$sth->bindParam(':image', $filename);
$sth->bindParam('::category_id', $category_id, PDO::PARAM_INT);
$sth->execute();
return true;
} else {
return false;
}
}
這裏是我的錯誤:
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in /MAMP/htdocs/*****/lib/DB.class.php on line 44
,如果我不使用bindParam
並添加工作正常數組鍵=>值對
任何想法這裏發生了什麼?
錯過了20分鐘的錯字。這是一個漫長的一天。謝謝。 – GV1 2011-12-16 22:52:58