php - Call to a member function fetch() on boolean in a sql request -
i trying fix bug php webpage, console returns me error : don't know how fix this.
[tue sep 12 10:04:36 2017] ::1:49319 [200]: /extranet_administrateur/questionnaire.php?id_site=1422 - call member function fetch() on boolean in /users/neqodev/desktop/cks-ocm-v3/extranet_administrateur/questionnaire.php on line 444
<?php while ($donnees = $req->fetch()) { $n = $n+1; $id_theme_question_q = $donnees['id_theme_question_q']; $nom_formsqlcategorie = $donnees['nom']; $reponse = $bdd->query("select * question_q id_site = $id_site , id_theme = '$id_theme_question_q' $requete_restriction"); $nbtotal = 0; $nbrepondu = 0; while ($donneesstotal = $reponse->fetch()) { $nbtotal++; if($donneesstotal['cignore']=='1' || !($donneesstotal['reponse_form']=='' ||$donneesstotal['reponse_form']==null)){ $nbrepondu++; } } $nbnonrepondu = $nbtotal - $nbrepondu; $pourcentage = $nbrepondu * 100 / $nbtotal; $pourcentage = number_format($pourcentage,2); $pourcentage_arr = floor($pourcentage); if($nbtotal==0){ $pourcentage = 100; $pourcentage_arr = floor($pourcentage); } ?>
thanks ! ;)
the $reponse variable 0 (boolean false) because select-statement returns 0 results
anyway, i'd suggest check errors after sql statement
$reponse = $bdd->query("select * question_q id_site = $id_site , id_theme = '$id_theme_question_q' $requete_restriction");
if (!$response) { print_r($bdd->errorinfo()); exit; }
Comments
Post a Comment