【发布时间】:2020-06-15 01:55:03
【问题描述】:
我不得不将 PHP 请求放在我的网站上,但我收到了这个错误。
我的错误:
致命错误:未捕获的错误:在 C:\wamp64\www\monsite\index.php 第 71 行的布尔值上调用成员函数 fetch()
错误:第 71 行 C:\wamp64\www\monsite\index.php 中的布尔值调用成员函数 fetch()
我的代码:
<?php
//Connexion PDO
try //afficher les erreurs de connection
{
$bdd = new PDO('mysql:host=localhost;bdname=bdd_site;charset=utf8','root','');
} catch (Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$contenu=$bdd->query('SELECT * FROM commentaire');
//on affiche chaque entrée
while($donnees=$contenu->fetch())
{
?>
<p> commentare de : <strong><?php echo $donnees['Pseudo'];?></strong></p>
<p> Note donnée par <strong> <?php echo $donnees['Pseudo'];?></strong> : <?php echo $donnees['Note']; ?></p>
<p> comment :</p>
<p style="color:red;"><?php echo $donnees['Comment'];?> </p>
<?php
}
$contenu->closeCursor(); //termine traitemennt requête
?>
【问题讨论】:
-
我想你会从这里得到更多的想法,stackoverflow.com/questions/32696192/…