-1

Below is my code for inserting data into mysql server. Whenever I try to add an email field to this is stops working ie, it does not save the data anymore.

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.html');

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

    if(empty($result)){ 
      $query = mysql_query("INSERT INTO users (oauth_provider, oauth_uid, username)         VALUES ('facebook', {$user_profile['id']}, '{$user_profile['name']},{$user_profile['education']} ')");  
       $query = msyql_query("SELECT * FROM users WHERE id = " . mysql_insert_id());  
      $result = mysql_fetch_array($query);  
       }  



   // 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);
     }


     ?>

Revised code, with email field

if(empty($result)){ 
  $query = mysql_query("INSERT INTO users (oauth_provider, oauth_uid, username)         VALUES ('facebook', {$user_profile['id']}, '{$user_profile['name']},{$user_profile['education']} ')");  
   $query = msyql_query("SELECT * FROM users WHERE id = " . mysql_insert_id());  
  $result = mysql_fetch_array($query);  
   }  
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82
Sammy Kumar
  • 121
  • 3
  • 15

1 Answers1

0

Follow the steps given in below tutorial you will have it.

http://www.skwebdesigner.com/?p=586

Dipesh Parmar
  • 27,090
  • 8
  • 61
  • 90