php – 致命错误:不支持的操作数类型

前端之家收集整理的这篇文章主要介绍了php – 致命错误:不支持的操作数类型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我继续收到以下错误,我想知道如何解决它.
  1. Fatal error: Unsupported operand types on line 97

它围绕下面列出的代码区域.如果需要,我可以列出完整的代码.

PHP代码

  1. $total_rating_points = MysqLi_fetch_array($result);
  2. if (!empty($total_rating_points) && !empty($total_ratings)){
  3. $avg = (round($total_rating_points / $total_ratings,1));
  4. $votes = $total_ratings;
  5. echo $avg . "/10 (" . $votes . " votes cast)";
  6. } else {
  7. echo '(no votes cast)';
  8. }

这是第97行

  1. $avg = (round($total_rating_points / $total_ratings,1));

这是完整的代码.

  1. function getRatingText(){
  2. $dbc = MysqLi_connect ("localhost","root","","sitename");
  3.  
  4. $page = '3';
  5.  
  6. $sql1 = "SELECT COUNT(*)
  7. FROM articles_grades
  8. WHERE users_articles_id = '$page'";
  9.  
  10. $result = MysqLi_query($dbc,$sql1);
  11.  
  12. if (!MysqLi_query($dbc,$sql1)) {
  13. print MysqLi_error($dbc);
  14. return;
  15. }
  16.  
  17. $total_ratings = MysqLi_fetch_array($result);
  18.  
  19. $sql2 = "SELECT COUNT(*)
  20. FROM grades
  21. JOIN articles_grades ON grades.id = articles_grades.grade_id
  22. WHERE articles_grades.users_articles_id = '$page'";
  23.  
  24. $result = MysqLi_query($dbc,$sql2);
  25.  
  26. if (!MysqLi_query($dbc,$sql2)) {
  27. print MysqLi_error($dbc);
  28. return;
  29. }
  30.  
  31. $total_rating_points = MysqLi_fetch_array($result);
  32. if (!empty($total_rating_points) && !empty($total_ratings)){
  33. $avg = (round($total_rating_points / $total_ratings,1));
  34. $votes = $total_ratings;
  35. echo $avg . "/10 (" . $votes . " votes cast)";
  36. } else {
  37. echo '(no votes cast)';
  38. }
  39. }
$total_rating_points是一个数组.你不能用数字来划分它.

猜你在找的PHP相关文章