Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:29:55+00:00 2026-06-14T22:29:55+00:00

Ok. Here is the code I have so far… mysql_query($userrating); $userratingquery = SELECT rating

  • 0

Ok. Here is the code I have so far…

mysql_query($userrating);
$userratingquery =  "SELECT rating FROM user_rating WHERE user_id=$sellerid";
$userrating = mysql_query($userratingquery) or die('SQL Error :: '.mysql_error());
$userrating = array();

while(($row =  mysql_fetch_assoc($userrating))) {
   $rating[] = $row['rating'];
}

if (!empty($userrating)) {
   $averagerating = array_sum($userratingary); 
   print_r($userratingary);
} else {
   echo '<img src="images/star.png" class="ratingstar" /><img src="images/star.png" class="ratingstar" /><img src="images/halfstar.png" class="ratingstar" />';
}

What I’m trying to do is create an array of the database values called “rating”, average the values in that array, then I want to round those values up. So, for instance, if the average of those values ends up being 3.7, then the average will then become 4.

From there I can apply the results to the code… I’m just having a lot of trouble with my array right now. The error I’m getting right now is…

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL
result resource in

Can someone point me in the right direction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:29:56+00:00Added an answer on June 14, 2026 at 10:29 pm

    Your problem is here:

    $userrating = mysql_query($userratingquery) or die('SQL Error :: '.mysql_error());
    $userrating = array();
    

    You are resetting the $userrating variable to an array so when you try to fetch a mysql row the $userrating mysql result is no longer valid.

    Use a different variable name for your $userrating array or else another one for your mysql result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a total newb to LINQ. Here is the code I have so far:
Here's the code I have: from cStringIO import StringIO from lxml import etree xml
Here's the code I have so far: $url = substr($url,0,10); This produces a URL
Here is the code I have thus far: import email, imaplib user = 'some
Here is the code I have so far: DECLARE @bcpCommand varchar(2000) DECLARE @query varchar(2000)
I am playing with XamlPadX and here is the code I have so far:
Here is the code I have so far: public static int mode(int[][] arr) {
So here is the code I have so far: Flex Code <?xml version=1.0 encoding=utf-8?>
Here is the code I have thus far: import java.io.*; class JAVAFilter implements FilenameFilter
Here is the code I have so far... // Run the external encryption process

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.