【发布时间】:2015-11-20 13:30:46
【问题描述】:
如何解决这个问题
可捕获的致命错误:不能是 PDOStatement 类的对象 转换成字符串。
我的 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');
【问题讨论】:
-
你在这里覆盖你的变量
$a:$a = $db->prepare($sql);;做一些基本的调试。