Catchable fatal error: Object of class PDOStatement could not be converted to string in
Catchable fatal error: Object of class PDOStatement could not be converted to string in
我的查询非常简单:但我不明白为什么我会得到这个 error=> 可捕获的致命错误:class PDOStatement 的对象无法转换为字符串
$sub_id=4;
include('inc/config.php');
echo $statement = $pdo->prepare("SELECT * FROM posts WHERE subid=:q");
$statement->execute(array(':q' => $sub_id));
while($row = $statement->fetch())
{
$tutor=$row['Name'];
}
你不能 echo
$statement
变量,因为它是一个 PDOStatement Object
所以你需要阅读如何使用 PDO :)
我的查询非常简单:但我不明白为什么我会得到这个 error=> 可捕获的致命错误:class PDOStatement 的对象无法转换为字符串
$sub_id=4;
include('inc/config.php');
echo $statement = $pdo->prepare("SELECT * FROM posts WHERE subid=:q");
$statement->execute(array(':q' => $sub_id));
while($row = $statement->fetch())
{
$tutor=$row['Name'];
}
你不能 echo
$statement
变量,因为它是一个 PDOStatement Object
所以你需要阅读如何使用 PDO :)