[英]Paypal IPN Script / MySql Insert Query issue
我的IPN腳本有問題。 驗證付款等很好,但是我試圖讓它將數據輸入數據庫。 之前的用戶電子郵件和密碼輸入正常,但第二個則無效。
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$email = $_POST['item_name'];
$password = mt_rand(1000, 9999);
$Random = print_r($_POST);
mysql_query("INSERT INTO users (email, password) VALUES('". mysql_escape_string($email) ."', '".md5($password)."') ") or die(mysql_error());
mysql_query("INSERT INTO LNCH_Sales SET
item_name = '%s',
item_number = '%s',
payment_status = '%s',
payment_amount = '%s',
payment_currency = '%s',
txn_id = '%s',
receiver_email = '%s',
payer_email = '%s'",
mysql_real_escape_string($item['name']),
mysql_real_escape_string($item['number']),
mysql_real_escape_string($payment['status']),
mysql_real_escape_string($payment['amount']),
mysql_real_escape_string($payment['currency']),
mysql_real_escape_string($txn['id']),
mysql_real_escape_string($receiver['email']),
mysql_real_escape_string($payer['email'])
);
有什么主意在這里嗎?
您的語法錯誤-而不是
INSERT INTO LNCH_SALES SET
(看起來像是INSERT和UPDATE之間的混合),您需要
INSERT INTO LNCH_SALES(<column_list>) VALUES (...
正如@FrankSchmitt可能說的那樣,您缺少列列表。
跳過列列表的唯一方法是,如果插入列數=表列數,即IE:
jcho360> create table test (id int,name varchar(20));
Query OK, 0 rows affected (0.05 sec)
jcho360> insert into test values (1,'Jcho360');
Query OK, 1 row affected (0.00 sec)
jcho360> insert into test values (1);
ERROR 1136 (21S01): Column count doesn't match value count at row 1
jcho360> insert into test(id) values (1);
Query OK, 1 row affected (0.01 sec)
如您所見,只有當我打算在“插入”中填充所有列時,才可以跳過列列表。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.