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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:54:47+00:00 2026-06-16T07:54:47+00:00

I am using the Facebook Graph API to get the genders from a list

  • 0

I am using the Facebook Graph API to get the genders from a list of Facebook users. I have the user’s IDs (they are current users of my app). For this, I won’t need to use the API because gender does not require special permissions (even though I have obtained the basic info permissions anyhow). Basically I’m using a while loop to loop through all the rows on a MySQL table which has stored the FB ids that I grabbed when the user uses the app. When I do the json_decode code outside the while loop, it works great (but obviously only grabs the first instance in the table). Then when I put it in a loop, the page just won’t load. It just sits and tries to load forever. Here’s the code:

$sql = "SELECT * FROM fb_id ORDER BY timestamp DESC";
$result = $mysqli->query($sql);                     

while($row = mysqli_fetch_array($result)){
                    $jsonurl = "https://graph.facebook.com/".$row['fb_id'];
                    $json = file_get_contents($jsonurl,0,null,null);
                    $json_output = json_decode($json);
                    $user_gender = $json_output->gender;
                    echo $user_gender;
                    }

                    while($row = mysqli_fetch_array($result)){
                    echo "<a href='http://www.facebook.com/".$row['fb_id']."' target='_blank'><img src='http://graph.facebook.com/".$row['fb_id']."/picture/' /></a>";
                    }

You’ll see the top bit of code is for the gender. The bottom loop is to display the user’s profile pictures. That bottom loop works fine.

Any ideas why the call to the Facebook Graph would be getting stuck? Thanks!

  • 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-16T07:54:48+00:00Added an answer on June 16, 2026 at 7:54 am

    The bottom loop is to display the user’s profile pictures. That bottom loop works fine.

    The bottom loop does too.

    Any ideas why the call to the Facebook Graph would be getting stuck?

    The Graph API is fine, no worries.

    You are looping over the Database query result once, to get the user details and echo out their gender.

    After that, the DB query result is at its end, no more rows to fetch.

    And that makes the condition of the second while loop become false at its first check, and so the loop content is not even executed once.

    Why did you put a second while loop there anyway? You are accessing the same column value there as in the first loop – so why not put the contents of both code blocks into one code block after one while keyword?

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

Sidebar

Related Questions

i'm using facebook graph api to get the current user friend list. i have
I'm using Facebook graph API for my iPhone app to get a list of
I'm using a foreach loop to get images from the graph API in facebook.
I am using the Facebook Graph API to get the users locale information (updated
I have a Json data retrieved from facebook using graph api, now i am
In my app i'm using Facebook Graph API and when I'm fetching user details
I'm using the Facebook Graph Api to load all friends of the current user
I am trying to get access token using from facebook graph API in my
Is there anyway to get a list of mutual friends using Facebook's Graph API?
i'm using graph api to connect to facebook. now i want to get the

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.