<small id='VS3pb'></small><noframes id='VS3pb'>

        <bdo id='VS3pb'></bdo><ul id='VS3pb'></ul>
      1. <tfoot id='VS3pb'></tfoot>
      2. <i id='VS3pb'><tr id='VS3pb'><dt id='VS3pb'><q id='VS3pb'><span id='VS3pb'><b id='VS3pb'><form id='VS3pb'><ins id='VS3pb'></ins><ul id='VS3pb'></ul><sub id='VS3pb'></sub></form><legend id='VS3pb'></legend><bdo id='VS3pb'><pre id='VS3pb'><center id='VS3pb'></center></pre></bdo></b><th id='VS3pb'></th></span></q></dt></tr></i><div id='VS3pb'><tfoot id='VS3pb'></tfoot><dl id='VS3pb'><fieldset id='VS3pb'></fieldset></dl></div>

      3. <legend id='VS3pb'><style id='VS3pb'><dir id='VS3pb'><q id='VS3pb'></q></dir></style></legend>

        警告问题:期望参数 1 为 mysqli_result

        时间:2023-07-30
        • <bdo id='jkYsR'></bdo><ul id='jkYsR'></ul>
            <tbody id='jkYsR'></tbody>
          <i id='jkYsR'><tr id='jkYsR'><dt id='jkYsR'><q id='jkYsR'><span id='jkYsR'><b id='jkYsR'><form id='jkYsR'><ins id='jkYsR'></ins><ul id='jkYsR'></ul><sub id='jkYsR'></sub></form><legend id='jkYsR'></legend><bdo id='jkYsR'><pre id='jkYsR'><center id='jkYsR'></center></pre></bdo></b><th id='jkYsR'></th></span></q></dt></tr></i><div id='jkYsR'><tfoot id='jkYsR'></tfoot><dl id='jkYsR'><fieldset id='jkYsR'></fieldset></dl></div>

              <small id='jkYsR'></small><noframes id='jkYsR'>

            1. <legend id='jkYsR'><style id='jkYsR'><dir id='jkYsR'><q id='jkYsR'></q></dir></style></legend>

              1. <tfoot id='jkYsR'></tfoot>
                  本文介绍了警告问题:期望参数 1 为 mysqli_result的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我收到下面列出的警告,我想知道如何修复它

                  I get the following warning listed below and I was wondering how do I fix it

                  Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given on line 65
                  

                  代码围绕下面列出的 PHP 代码部分.如果需要,我可以列出完整的代码.

                  The code is around this section of PHP code listed below. I can list the full code if needed.

                  // function to retrieve average and votes
                  function getRatingText(){
                      $dbc = mysqli_connect ("localhost", "root", "", "sitename");
                      $sql1 = "SELECT COUNT(*) 
                               FROM articles_grades 
                               WHERE users_articles_id = '$page'";
                  
                      $result = mysqli_query($dbc,$sql1);
                      $total_ratings = mysqli_fetch_array($result);
                  
                      $sql2 = "SELECT COUNT(*) 
                               FROM grades 
                               JOIN grades ON grades.id = articles_grades.grade_id
                               WHERE articles_grades.users_articles_id = '$page'";
                  
                      $result = mysqli_query($dbc,$sql2);
                      $total_rating_points = mysqli_fetch_array($result);
                      if (!empty($total_rating_points) && !empty($total_ratings)){
                          $avg = (round($total_rating_points / $total_ratings,1));
                          $votes = $total_ratings;
                          echo $avg . "/10  (" . $votes . " votes cast)";
                      } else {
                          echo '(no votes cast)';
                      }
                  }
                  

                  推荐答案

                  mysqli_query() 如果查询中有错误,则返回 FALSE.所以你应该测试一下...

                  mysqli_query() returns FALSE if there was an error in the query. So you should test for it...

                  /* Select queries return a resultset */
                  if ($result = mysqli_query($dbc, "SELECT Name FROM City LIMIT 10")) {
                      printf("Select returned %d rows.
                  ", $result->num_rows);
                  
                      /* free result set */
                      $result->close();
                  }
                  

                  请参阅此链接以获取 mysqli_query 参考http://php.net/manual/en/mysqli.query.php

                  See this link for the mysqli_query reference http://php.net/manual/en/mysqli.query.php

                  这篇关于警告问题:期望参数 1 为 mysqli_result的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:警告:mysqli_query() 需要至少 2 个参数,1 个给定.什 下一篇:在准备好的语句上使用 fetch_assoc (php mysqli)

                  相关文章

                  最新文章

                  <tfoot id='bc7gc'></tfoot>
                  <i id='bc7gc'><tr id='bc7gc'><dt id='bc7gc'><q id='bc7gc'><span id='bc7gc'><b id='bc7gc'><form id='bc7gc'><ins id='bc7gc'></ins><ul id='bc7gc'></ul><sub id='bc7gc'></sub></form><legend id='bc7gc'></legend><bdo id='bc7gc'><pre id='bc7gc'><center id='bc7gc'></center></pre></bdo></b><th id='bc7gc'></th></span></q></dt></tr></i><div id='bc7gc'><tfoot id='bc7gc'></tfoot><dl id='bc7gc'><fieldset id='bc7gc'></fieldset></dl></div>

                • <legend id='bc7gc'><style id='bc7gc'><dir id='bc7gc'><q id='bc7gc'></q></dir></style></legend>

                    <small id='bc7gc'></small><noframes id='bc7gc'>

                      <bdo id='bc7gc'></bdo><ul id='bc7gc'></ul>