使用Facebook PHP SDK。我在兩個不同的文件中具有相同的.php標記,在一個工作中,但在另一個文件中,它不返回任何內容。任何想法?我在兩個文件中都包含相同的config.php
文件。mysql_fetch_array和Facebook API
include("config.php");
include("fbconnect.php");
if (!isset($_SESSION['user']))
{
$valor_voto = mysql_query("select voto from $mes_id where email=$email");
$row = mysql_fetch_array($valor_voto);
$valor = $row['voto'];
if ($valor == 1)
{
echo '<img class="icon" src="/images/greencheck.png">';
}
else
{
echo '<img class="icon" src="/images/check.png">';
}
}
else
{
echo '<img class="icon" src="/images/check.png">';
}
看來,我認爲$email
就是失敗,因爲如果我輸入電子郵件手動它將返回任何2個spectated值。
謝謝你的時間。
$email
來自fbconnect.php
:
if ($user)
{
try
{
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
//Connecting to the database. You would need to make the required changes in the common.php file
//In the common.php file you would need to add your Hostname, username, password and database name!
mysqlc();
$name = GetSQLValueString($user_profile['name'], "text");
$email = GetSQLValueString($user_profile['email'], "text");
$gender = GetSQLValueString($user_profile['gender'], "text");
$bio = GetSQLValueString($user_profile['bio'], "text");
$hometown = GetSQLValueString($user_hometown['hometown'], "text");
$query = sprintf("SELECT * FROM newmember WHERE email = %s", $email);
$res = mysql_query($query) or die('Query failed: ' . mysql_error() . "<br/>\n$sql");
if (mysql_num_rows($res) == 0)
{
$iquery = sprintf("INSERT INTO newmember values('',%s,%s,%s,%s,'yes',%s)", $name, $email, $gender, $bio, $hometown);
$ires = mysql_query($iquery) or die('Query failed: ' . mysql_error() . "<br/>\n$sql");
$_SESSION['user'] = $user_profile['email'];
$_SESSION['id'] = $user_profile['id'];
}
else
{
$row = mysql_fetch_array($res);
$_SESSION['user'] = $row['email'];
$_SESSION['id'] = $user_profile['id'];
}
}
catch (FacebookApiException $e)
{
error_log($e);
$user = NULL;
}
}
$ email從哪裏來? – Maerlyn
請注意,'mysql_xx()'函數被認爲已經過時,並且被PHP棄用。所有這些函數的php手冊頁面都包含一個大的紅色框,表示不使用它們,並切換到'mysqli_xx()'函數或PDO庫。如果可能,我強烈建議進行此更改。 – Spudley
@Maerlyn我添加了$ email的源代碼。 Thx的時候,我正在考慮php手冊中提出的新方法。 –