-5
如何解決這個PHP,MySQL錯誤插入數據
Catchable fatal error: Object of class PDOStatement could not be converted to string in.
我的PHP代碼:
$a = $_POST['id'];
$b = $_POST['title'];
$c = $_POST['cat'];
$d = $_POST['cop'];
$e = $_POST['stat'];
$sql = "INSERT INTO books (book_id, book_title, book_category, no_copies, status) VALUES (:a,:b,:c,:d,:e)";
$a = $db->prepare($sql);
$a->execute(array(':a'=>$a, ':b'=>$b, ':c'=>$c, ':d'=>$d, ':e'=>$e));
header('Location: books.php');
[以下是如何綁定參數(http://php.net/manual/es/pdostatement.bindparam.php) –
你覆蓋你的變量' $ a'在這裏:'$ a = $ db-> prepare($ sql);';做一些基本的調試。 – Rizier123