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 8422081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:20:18+00:00 2026-06-10T03:20:18+00:00

I’m currently creating a page in PHP that will display a user and their

  • 0

I’m currently creating a page in PHP that will display a user and their ranks in my site’s high scores.

I had a problem where my MySQL query wasn’t functioning as intended, however, @VladBalmos solved my problem here: MySQL Highscores – User's Personal Ranks: Duplicate Entries Causing Incorrect Values

Now that I believe my MySQL query is functioning, I need to address the issues that arose with my PHP Code. Here is my code:

$userid = (int) $_GET['searched'];
    for ($i = 0; $i < 5; $i++) {
        if ($i == 0) {
            $skill_query = mysqli_query($database, "SELECT uid, overall, overallxp, gamelevel FROM playerstats WHERE uid = ". $userid ." ORDER BY playerstats.overall DESC, playerstats.overallxp DESC") or print(mysqli_error($database));
            $skill_array = mysqli_fetch_array($skill_query);
            //old rank query: $rank_query = mysqli_query($database, "SELECT count(*) + 1 FROM (SELECT uid, overall, overallxp, gamelevel FROM playerstats GROUP BY playerstats.uid) AS x WHERE overall > (SELECT overall FROM playerstats WHERE uid = ". $userid .")") or print(mysqli_error($database));
            $rank_query = mysqli_multi_query($database, "SET @rank=0; SELECT rank, uid, overall, overallxp FROM (SELECT @rank:=@rank + 1 AS rank, uid, overall, overallxp FROM playerstats ORDER BY overall DESC, overallxp DESC) as tmp") or print(mysqli_error($database));
            $rank_array = mysqli_fetch_array($rank_query);
        } else {
            $skill_query = mysqli_query($database, "SELECT uid, ". $skills[$i] .", gamelevel FROM playerstats WHERE uid = ". $userid ." ORDER BY playerstats.". $skills[$i] ." DESC, playerstats.gamelevel DESC") or print(mysqli_error($database));
            $skill_array = mysqli_fetch_array($skill_query);
            $rank_query = mysqli_query($database, "SELECT count(*) + 1 FROM (SELECT uid, ". $skills[$i] .", gamelevel FROM playerstats GROUP BY playerstats.uid) AS x WHERE ". $skills[$i] ." > (SELECT ". $skills[$i] ." FROM playerstats WHERE uid = ". $userid .")") or print(mysqli_error($database));
            $rank_array = mysqli_fetch_array($rank_query);
        }
    
        echo "<tr class='hs_row'>";
        echo "<td align='center'>";
        echo $rank_array[0]; //rank output
        echo "</td>";
        echo "<td align='center'>";
        echo $skill_array[1]; //skilllevel
        echo "</td>";
        echo "<td align='center'>";
        if ($i == 0) {
            echo number_format($skill_array[2]); //skillxp
        } else {
            echo number_format($skill_array[1]); //skillxp
        }
        echo "</td></tr>";
    }

…and the error I am receiving is:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in [path]/personal.php on line 156

Commands out of sync; you can’t run this command now

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in [path]/personal.php on line 159

Commands out of sync; you can’t run this command now

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in [path]/personal.php on line 161

Commands out of sync; you can’t run this command now

So, my question is, how do I correct this error?

  • 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-10T03:20:19+00:00Added an answer on June 10, 2026 at 3:20 am
    $rank_query = mysqli_multi_query($database, $yourQuery);
    if($rank_query) {
        while(mysqli_next_result($dabatase)) {
            if($result = mysqli_store_result($database)) {
                while($row = mysqli_fetch_row($result) {
                    // do something
                }
            }
    
        }
    }
    

    you have to loop through the results of your multiple queries and then access the rows for each result set. Since the first query just sets a variable you have to skip to the next result set and fetch the actual rows (that’s why i did *while(mysqli_next_result…*)
    read the docs at the php manual

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.