php – 致命错误:不支持的操作数类型
发布时间:2020-12-13 13:03:53 所属栏目:PHP教程 来源:网络整理
导读:我继续收到以下错误,我想知道如何解决它. Fatal error: Unsupported operand types on line 97 它围绕下面列出的代码区域.如果需要,我可以列出完整的代码. PHP代码 $total_rating_points = mysqli_fetch_array($result);if (!empty($total_rating_points) !e
我继续收到以下错误,我想知道如何解决它.
Fatal error: Unsupported operand types on line 97 它围绕下面列出的代码区域.如果需要,我可以列出完整的代码. PHP代码 $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)'; } 这是第97行 $avg = (round($total_rating_points / $total_ratings,1)); 这是完整的代码. function getRatingText(){ $dbc = mysqli_connect ("localhost","root","","sitename"); $page = '3'; $sql1 = "SELECT COUNT(*) FROM articles_grades WHERE users_articles_id = '$page'"; $result = mysqli_query($dbc,$sql1); if (!mysqli_query($dbc,$sql1)) { print mysqli_error($dbc); return; } $total_ratings = mysqli_fetch_array($result); $sql2 = "SELECT COUNT(*) FROM grades JOIN articles_grades ON grades.id = articles_grades.grade_id WHERE articles_grades.users_articles_id = '$page'"; $result = mysqli_query($dbc,$sql2); if (!mysqli_query($dbc,$sql2)) { print mysqli_error($dbc); return; } $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)'; } }
$total_rating_points是一个数组.你不能用数字来划分它.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |