2017-09-12 31 views
-2

我試圖修復一個來自PHP網頁的錯誤,控制檯返回這個錯誤:我不知道如何解決這個問題。調用一個sql請求中的布爾值的成員函數fetch()

[星期二年09月12 10點04分36秒2017] :: 1:49319 [200]:/extranet_administrateur/questionnaire.php?id_site=1422 - 調用一個成員函數fetch()方法在布爾在/用戶/neqodev/Desktop/cks-ocm-v3/extranet_administrateur/questionnaire.php上線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 * FROM question_q where id_site = $id_site and 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); 
     } 
?> 

謝謝! ;)

+5

的[調用一個成員功能的非對象上]可能的複製(https://stackoverflow.com/questions/54566/call-to-a-member-function-on-a-非對象) – CBroe

回答

1

的$效應初探變量可以是0(布爾值false),因爲你的select語句返回結果爲零

反正,我建議您在SQL語句後檢查錯誤

$ reponse = $ bdd-> query(「SELECT * FROM question_q where id_site = $ id_site and id_theme ='$ id_theme_question_q'$ requete_restriction」);

if (!$response) { 
    print_r($bdd->errorInfo()); 
    exit; 
} 
+0

我的控制檯什麼也沒有打印 –

+0

這很好!這意味着沒有錯誤,但您的查詢返回零結果! –

相關問題