使用 Facebook PHP SDK。我在两个不同的文件中有相同的 .php 标签,在一个文件中它可以工作,但在另一个文件中它什么也不返回。任何的想法?我config.php
在两者中都包含相同的文件。
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 个预期值中的任何一个。
谢谢你的时间。
$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;
}
}