title: PHP - Fatal error: Unsupported operand types
body: <p>I keep getting the following error and I was wondering on how to fix?</p>
  
  <p>This is the second time I got this error I fixed it the first time but for some reason I cant fix it the second time.</p>
  
  <pre><code>Fatal error: Unsupported operand types on line 103
  </code></pre>
  
  <p>Here is line 103.</p>
  
  <pre><code>$avg = (round($total_rating_points / $total_ratings,1));
  </code></pre>
  
  <p>Here is the full code below.</p>
  
  <pre><code>function getRatingText(){
      $dbc = mysqli_connect ("localhost", "root", "", "sitename");
  
      $page = '3';
  
      $sql1 = "SELECT COUNT(users_articles_id) 
               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 grade_points 
               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;
      }
  
      while($row = mysqli_fetch_array($result)) {
  
          $trp[] = $row[0];
      }
  
      $total_rating_points = array_sum($trp);
  
      if (!empty($total_rating_points) &amp;&amp; !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)';
      }
  }
  </code></pre>