inserting facebook app users details to database
        Posted  
        
            by fusion
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by fusion
        
        
        
        Published on 2010-05-12T18:58:04Z
        Indexed on 
            2010/05/15
            17:34 UTC
        
        
        Read the original article
        Hit count: 220
        
i'm trying to insert user details, who authorize the app, into the database, but nothing seems to be happening. the data is null and no record is being inserted. is there something wrong with the code?
function insertUser($user_id,$sk,$conn)
{
    //$info = $facebook->api_client->users_getInfo($user_id, 'first_name, last_name', 'name', 'sex');
    $info = $facebook->api_client->fql_query("SELECT uid, first_name, last_name, name, sex FROM user WHERE uid = $user_id");
    for ($i=0; $i < count($info); $i++) {
    $record = $info[$i]; 
    $first_name=$record['first_name'];
    $last_name=$record['last_name'];
    $full_name=$record['name'];
    $gender=$record['sex'];
    }
    $data= mysql_query("select uid from users where uid='{$user_id}'",$conn);
    if(mysql_num_rows($data)==0)
    {
        $sql = "INSERT INTO users (uid,sessionkey, active, fname, lname, full_name, gender) VALUES('{$user_id}','{$sk}','1', '{$first_name}', '{$last_name}', '{$full_name}', '{$gender}')";
        mysql_query($sql,$conn);
        return true;
    }
    return false;
}
        © Stack Overflow or respective owner