2012-05-24 55 views
0

我遇到了我的IPN腳本的問題。 它很好的驗證付款等,但即時通訊試圖讓它輸入數據到數據庫。 用戶的電子郵件和之前的優秀作品,但不是第二個密碼輸入..PayPal IPN Script/MySql插入查詢問題

$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']) 

                    ); 

任何想法有什麼錯在這裏?

回答

4

你的語法是錯誤的 - 而不是

INSERT INTO LNCH_SALES SET 

(看起來像INSERT和UPDATE之間的混合物),你需要

INSERT INTO LNCH_SALES(<column_list>) VALUES (... 
0

爲@FrankSchmitt說problably你缺少列列表。

,你可以跳過欄列表中的唯一方法是,如果插入的列數=表中的列數,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) 

正如你只能看到,如果我goning全部加滿「插入」中的列可以跳過列列表。