-1

下面是我将数据插入 mysql 服务器的代码。每当我尝试向其中添加电子邮件字段时,它都会停止工作,即它不再保存数据。

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


     ?>

修改后的代码,带有电子邮件字段

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

1 回答 1

0

按照下面教程中给出的步骤,您将拥有它。

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

于 2013-03-04T05:28:06.617 回答