0

FacebookPHPSDKの操作。2つの異なるファイルに同じ.phpタグがあり、1つは機能しますが、もう1つは何も返しません。何か案が?両方に同じ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;
    }
}
4

2 に答える 2

1

メール列は文字列であると想定しているため、値を引用符で囲む必要があります。また、Facebook からの SQL インジェクション攻撃を防ぐために、これをエスケープする必要があります。

$valor_voto=mysql_query("select voto from $mes_id where email='".mysql_real_escape_string($email)."'");

非推奨の mysql 拡張機能ではなく、mysqli または PDO を使用することをお勧めします。そうすれば、置換やエスケープではなく、準備済みステートメントを使用できます。

于 2012-10-26T19:30:32.533 に答える
0

解決しました、私は状態を持っていました

if(!isset($_SESSION['user']))

しかし、私は条件を与えていませんでした

if(isset($_SESSION['user']))

そのため、情報を取得できませんでした。

時間をありがとう。

于 2012-10-27T23:32:44.237 に答える