-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