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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:10:33+00:00 2026-06-09T22:10:33+00:00

I am collecting data on FB and sending it to my DB. My app

  • 0

I am collecting data on FB and sending it to my DB. My app is running, and I can see the data is inserted on my DB, but I am getting an error that I dont know how to solve. I have researched for this and tried some solutions without results. I added a line of code to see what was the error. Please guide me to solve it. Thanks

Error:

 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
 Unknown column 'id' in 'where clause'

The error points me at this line:

 $result = mysql_fetch_array($query) or die ( mysql_error () );  

This is my code:

<?php
define('db_user','xxx');
define('db_password','xxx');
define('db_host','xxx.xxx.com');
define('db_name','xxx');

// Connect to MySQL
 $dbc = @mysql_connect (db_host, db_user, db_password) OR die ('Could not connect to      MySQL: ' . mysql_error() );
// Select the correct database
mysql_select_db (db_name) OR die ('Could not select the database: ' . mysql_error() );
mysql_set_charset('utf8',$dbc);

require 'src/facebook.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId'  => 'xxxx',
'secret' => 'xxxx',
  'cookie' => true));


// Get User ID
 $user = $facebook->getUser();

// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.

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



   } catch (FacebookApiException $e) {
   error_log($e);
   $user = null;
   }
     }else{
   header('Location: index.php');

    }

      $query = mysql_query("SELECT * FROM users WHERE oauth_provider = 'facebook' AND     oauth_uid = ". $user_profile['id']);  
      $result = mysql_fetch_array($query);  


    if(empty($result)){ 
      $query = mysql_query("INSERT INTO users (oauth_provider, oauth_uid, username, first_name, last_name, birthday, email, pic_square ) VALUES    ('facebook', {$user_profile['id']}, '{$user_profile['name']}', '{$user_profile['first_name']}','{$user_profile['last_name']}','{$user_profile['birthday']}','{$user_profile['email']}', '{$user_profile['pic_square']}')");  
  $query = mysql_query("SELECT * FROM users WHERE id = " . mysql_insert_id());  
  $result = mysql_fetch_array($query) or die ( mysql_error () );  


 }  


   // Login or logout url will be needed depending on current user state.
    if ($user) {
     $paramsout = array('next'=>'http://www.mywebsite.com/test/logout.php');
     $logoutUrl = $facebook->getLogoutUrl($paramsout);
     }
     ?>
     <html><body>welcome</body></html>
  • 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-09T22:10:35+00:00Added an answer on June 9, 2026 at 10:10 pm

    I believe the query that fails is this one:

    $query = mysql_query("SELECT * FROM users WHERE id = " . mysql_insert_id()); 
    

    As the error message says, the table users doesn’t contain a field called id.

    Check the field name in the database, update the query and it should work.

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

Sidebar

Related Questions

I am developing large data collecting ASP.Net/Windows service application-pair that uses Microsoft SQL Server
I have written an extension method to help with collecting crash data during error
I'm getting data out of an XML file by sending a where clause as
Following snippet should be collecting data and sending it to a php file. It
Hi i'm working on an app that gets data from DB using WCF Service.
I am collecting data every five minutes and entering it into a MySQL database.
Are there any .NET frameworks for collecting data similar to Google Analytics, for example
We have a data collection system that collects measurements from environmental sensors that measure
I have a MongoDB collection with data that was not saved through my Derby
I have a small data collection app which has a single button to start

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.