首页 > 解决方案 > 可捕获的致命错误:无法将 PDOStatement 类的对象转换为第 40 行 D:\wamp64\www\blog\modal\CommentManager.php 中的字符串

问题描述

$bdd=$this->dbConnect();
$comment=$bdd->prepare('UPDATE commentaires SET commentaire=? WHERE id=? ');
$comment->execute(array($comment,$idComment));
$comment->fetch();
return $comment;

更新不起作用:此代码给我一个错误execute()

可捕获的致命错误:无法将 PDOStatement 类的对象转换为第 40 行 D:\wamp64\www\blog\modal\CommentManager.php 中的字符串

标签: php

解决方案


您将$comment用作变量PDOStatement并再次用作第一个输入参数的值。

更改(array($comment, $idComment)(array($textComment, $idComment)

<?php
$bdd = $this->dbConnect();
$comment = $bdd->prepare('UPDATE commentaires SET commentaire=? WHERE id=? ');
$comment->execute(array($textComment, $idComment));
$comment->fetch();
return $comment;
?>

推荐阅读