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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:57:08+00:00 2026-06-16T03:57:08+00:00

Possible Duplicate: php array not returning on first load Hi this is driving me

  • 0

Possible Duplicate:
php array not returning on first load

Hi this is driving me nuts. I posted in another SO forum before i realised there was a Facebook specific forum, but didnt have much luck. So apologies for re-post.

I have a Facebook login script that accesses the users’ profile. it then re-directs to, and populates, a page with a register form with all of their profile information.

This code jumps through all the right hoops, but the problem is that the variable $fqlResult is not being populated the first time the page loads, and therefore the form remains blank.

If i hit f5, the page reloads, $fqlResult returns the correct data and the form is populated.

  <?php
  $is_fb = false;
  $is_linkedin = false;
  $reg_method = $_GET['conn_social'];

  if (isset($_GET['in_uid'])){
    $cur_in_uid = $_GET['in_uid'];
  }

  if ($reg_method == "facebook"){
    $is_fb = true;
  }
  else if ($reg_method == "linkedin"){
    $is_linkedin = true;
  }

  if($is_fb) {
    global $fbconfig;
    $facebook = new Facebook(array( 'appId'  => $fbconfig['appid'],
                                    'secret' => $fbconfig['secret'],
                                    'cookie' => true ));

    $user = $facebook->getUser();

    if ($user) {
      try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile = $facebook->api('/me');


      } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
      }
    }

    $is_fb_uid_exist = hl_check_fb_uid_exist($user_profile['id']);

    if($is_fb_uid_exist){
      $is_fb = false;
    }

    try{
      $fql = "select name, first_name, last_name, birthday_date, sex, profile_url, hometown_location, current_location, work, activities, interests, music, tv, movies, books, quotes, about_me, website, education, sports, inspirational_people, languages, pic_square from user where uid=" . $user;

      $param = array( 'method'    => 'fql.query',
                      'query'     => $fql,
                      'callback'  => '' );

      //This is returning a blank dataset on the first page load. If you refresh the page, then the array is populated.
      $fqlResult = $facebook->api($param);
    }

 }
?>

After this each field is populated with a call that looks something life this

 <?php elseif($is_fb && isset($fqlResult[0]['first_name'])) : ?>

    <input type="text" name="hl_first_name" id="hl_first_name" style="width:130px;" value="<?php echo $fqlResult[0]['first_name']; ?>" />  
  • 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-16T03:57:10+00:00Added an answer on June 16, 2026 at 3:57 am

    Supply the access token in the $param, you will get the result in the first load.

     $param = array( 'method'    => 'fql.query',
                      'query'     => $fql,
                      'access_token' => ACCESS_TOKEN,
                      'callback'  => '' );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: php multi-dimensional array remove duplicate I have an array like this: $a
Possible Duplicate: PHP, Echoing an array into a string of comma seperated values This
Possible Duplicate: PHP : Array key containing special character not found I am comparing
Possible Duplicate: How check any value of array exist in another array php? I
Possible Duplicate: How do I sort a multidimensional array in php ........ This is
Possible Duplicate: Reference: Why does the PHP code in my Javascript not work? This
Possible Duplicate: php sort array by sub-value I have a multidimensional array like the
Possible Duplicate: PHP get both array value and array key I am using Codeigniters'
Possible Duplicate: In PHP, how do you change the key of an array element?
Possible Duplicate: How to delete an element from an array in php? For instance,

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.