0

Parse error: syntax error, unexpected T_STRINGこのコードは行で解析エラーを出している$gender=$user['gender'];.....このコードの何が問題なのか...助けが必要.....ありがとう

<?php
 require_once 'config/functions.php';
 session_start();
 $user=$_SESSION['google_data'];
 if(!empty($user)){
  $email = $user['email'];
  $fname = $user['given_name'];
  $lname = $user['family_name'];
  $gender=$user['gender'];
  $dob = $user['birthday'];
  $location = '';
  $picture = $user['picture'];
  $uid = $user['id'];
  $ousername = '';
  $link = $user['link'];
       $provider = 'google';
       $verified = $user['verified_email'];

      $gen=0;
      if($gender == 'male'){$gen=1;} else{$gen=0;}
      $new_dob = date( "Y-m-d H:i:s", strtotime($dob) );

      $userObj = new User();
      $userdata = $userObj->checkUser($email,$fname,$lname,$gen,$new_dob,$location,$picture,$uid,$ousername,$link,$provider,$new_verified); 
      if(!empty($userdata)){         
        $_SESSION['id'] = $userdata['user_id'];
        $_SESSION['oauth_id'] = $userdata['user_oauth_id'];
        $_SESSION['username'] = $userdata['user_oauth_username'];
        $_SESSION['picture'] = $userdata['picture'];            
        $_SESSION['link'] = $userdata['link'];
        $_SESSION['fname'] = $userdata['user_fname'];
        $_SESSION['lname'] = $userdata['user_lname'];
        $_SESSION['gender'] = $userdata['user_gender'];
        $_SESSION['email'] = $userdata['user_email'];
        $_SESSION['oauth_provider'] = $userdata['user_oauth_provider'];             
        $_SESSION['oauth_id'] = $uid;


     } else {
        # For testing purposes, if there was an error, let's kill the script
        die("There was an error.");

    }
  }
 ?>
4

3 に答える 3

1

次の行が問題である可能性があります。

     }
     } そうしないと {

于 2013-03-18T10:41:43.837 に答える
1

}余分な最後の理由から削除する必要があります。

最終行になります。

} else {
      # For testing purposes, if there was an error, let's kill the script
      die("There was an error.");
 }

完全なコード

<?php
    require_once 'config/functions.php';
    session_start();
    $user=$_SESSION['google_data'];

    if(!empty($user))
    {
        $email = $user['email'];
        $fname = $user['given_name'];
        $lname = $user['family_name'];
        $gender=$user['gender'];
        $dob = $user['birthday'];
        $location = '';
        $picture = $user['picture'];
        $uid = $user['id'];
        $ousername = '';
        $link = $user['link'];
        $provider = 'google';
        $verified = $user['verified_email'];

        $gen=0;
        if($gender == 'male'){$gen=1;} else{$gen=0;}

        $new_dob = date( "Y-m-d H:i:s", strtotime($dob) );

        $userObj = new User();
        $userdata = $userObj->checkUser($email,$fname,$lname,$gen,$new_dob,$location,$picture,$uid,$ousername,$link,$provider,$new_verified); 

        if(!empty($userdata))
        {
            $_SESSION['id'] = $userdata['user_id'];
            $_SESSION['oauth_id'] = $userdata['user_oauth_id'];
            $_SESSION['username'] = $userdata['user_oauth_username'];
            $_SESSION['picture'] = $userdata['picture'];            
            $_SESSION['link'] = $userdata['link'];
            $_SESSION['fname'] = $userdata['user_fname'];
            $_SESSION['lname'] = $userdata['user_lname'];
            $_SESSION['gender'] = $userdata['user_gender'];
            $_SESSION['email'] = $userdata['user_email'];
            $_SESSION['oauth_provider'] = $userdata['user_oauth_provider'];             
            $_SESSION['oauth_id'] = $uid;

        }
    }
    else
    {
        die("There was an error.");
    }
?>
于 2013-03-18T10:55:32.000 に答える
0

こんな感じで使ってください

$gender = isset( $user['gender'] ) ? $user['gender'] : '' ;
于 2013-03-18T10:52:50.117 に答える