Php Paypal IPN-后var

Php Paypal IPN-后var,php,paypal,paypal-ipn,Php,Paypal,Paypal Ipn,代码一直工作到第3个复选框,然后当我将它们导入数据库时,我会得到一个空行,有时甚至什么都没有。当我使用 如果($_服务器['REQUEST_方法]!=“POST”)死亡(“无POST变量”) 在顶部的代码中,我得到“No Post Variables”,但我可以使用Post变量检查是否有错误。我看到了从ipn返回的item变量,因为我可以使用它们,但是当我将它们导入db时,它们不会出现 为什么我不能将它们添加到数据库中 我已经在这个IPN上工作了一个星期,但没有结果 if ($_SERV

代码一直工作到第3个复选框,然后当我将它们导入数据库时,我会得到一个空行,有时甚至什么都没有。当我使用

如果($_服务器['REQUEST_方法]!=“POST”)死亡(“无POST变量”)

在顶部的代码中,我得到“No Post Variables”,但我可以使用Post变量检查是否有错误。我看到了从ipn返回的item变量,因为我可以使用它们,但是当我将它们导入db时,它们不会出现

为什么我不能将它们添加到数据库中

我已经在这个IPN上工作了一个星期,但没有结果

    if ($_SERVER['REQUEST_METHOD'] != "POST") die ("No Post Variables"); 


    $req = 'cmd=_notify-validate';

    foreach ($_POST as $key => $value) {
        $value = urlencode(stripslashes($value));
        $req .= "&$key=$value";
    }

    $url = "https://sandbox.paypal.com/cgi-bin/webscr";
    //$url = "https://www.paypal.com/cgi-bin/webscr";
    $curl_result=$curl_err='';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
    curl_setopt($ch, CURLOPT_HTTPHEADER array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($req)));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
    curl_setopt($ch, CURLOPT_HEADER , 0);   
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    $curl_result = @curl_exec($ch);
    $curl_err = curl_error($ch);
    curl_close($ch);

    $req = str_replace("&", "\n", $req); 



    // Check Number 1 ------------------------------------------------------------------------------------------------------------
    $receiver_email = $_POST['receiver_email'];
    if ($receiver_email != "samuel_1347268213_biz@hotmail.com") {
        $message = "Investigate why and how receiver email is wrong. Email = " . $_POST['receiver_email'] . "\n\n\n$req";
        mail("@hotmail.com", "Receiver Email is incorrect", $message, "From: samuel_1347268213_biz@hotmail.com" );
        exit(); // exit script
    }
    // Check number 2 ------------------------------------------------------------------------------------------------------------
    if ($_POST['payment_status'] != "Completed") {
        // Handle how you think you should if a payment is not complete yet, a few scenarios can cause a transaction to be incomplete
        mail("@hotmail.com", "payment_status", $message, "From: samuel_1347268213_biz@hotmail.com" );
    }

    // Connect to database ------------------------------------------------------------------------------------------------------
    require_once 'connect_to_mysql.php';

    // Check number 3 ------------------------------------------------------------------------------------------------------------
    $payer_email = $_POST['payer_email'];
    $sql = mysql_query("SELECT * FROM transactions WHERE payer_email= '".$payer_email."' LIMIT 1");
    $numRows = mysql_num_rows($sql);
    if ($numRows > 0) {
        $message = "Duplicate transaction ID occured so we killed the IPN script. \n\n\n$req";
        mail("@hotmail.com", "Duplicate txn_id in the IPN system", $message, "From: samuel_1347268213_biz@hotmail.com" );
        exit(); // exit script



$txn = $_POST['txn_id'];

$payer = $_POST['payer_email'];



$l = "INSERT INTO  transactions (txn_id,payer_email)VALUES ('".$txd ."','".$payer ."')";

mysql_query($l)or die;


// Mail yourself the details
$req .= "\n\nDataverified from Paypal!";
mail("@hotmail.com", "NORMAL IPN+++ RESULT", $req, "From: samuel_1347268213_biz@hotmail.com");

尝试调试MySQL。检查:'$sql===false'(在检查3之后)如果($numRows>0)您没有关闭
if
,我也不会真正使用
exit()更好地处理它。我不会得到任何sql错误。最好总是将条件括在花括号内。@samuel当然,如果不检查MySQL错误,就不会得到任何错误。