0
我使用貝寶IPN,這是我如何將數據發送到貝寶:PHP/PDO語句使「0」
require_once 'classes/Crypt.php';
$crypt = new Crypt();
$crypt->Mode = Crypt::MODE_HEX;
$crypt->Key = '§$TERGERG§$T§34t';
$test = array('cmd'=>'_xclick',
'business'=>'meine_email',
'notify_url'=> 'url_zum_ipn',
'item_name'=>'name',
'amount'=>'1.00',
'currency_code'=>'USD',
'lc'=>'US',
'custom'=>$crypt->encrypt(serialize(array("username" => $username))));
$url = "https://www.sandbox.paypal.com/cgi-bin/webscr?".http_build_query($test);
header("Location:".$url);
exit();
這是我如何處理我的IPN腳本數據:
require_once '../classes/Crypt.php';
$crypt = new Crypt();
$crypt->Mode = Crypt::MODE_HEX;
$crypt->Key = '§$TERGERG§$T§34t';
$custom = unserialize($crypt->decrypt($_POST["custom"]));
$username = $custom['username'];
try
{
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbh->prepare("INSERT INTO products (product_name)
VALUES (?)");
$stmt->bindParam(1, $value1);
$value1 = $username;
$stmt->execute();
}
catch(PDOException $exception)
{
$body .= "Error: " . $exception->getMessage() . "\n";
}
沒有插入我的表,但此消息:
Error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column
'product_name' cannot be null
我檢查變量$用戶名在開始發送時,它是! 但我對這個檢查變量$的用戶名在IPN腳本:
if($username == "") { // gives true
所以任何人知道哪裏是我的錯誤的代碼?問候!
請格式化你的代碼 –