2017-02-11 37 views
0

顯示在日誌或沒有錯誤我有一個小問題,我對如何解決這個問題,從來就想盡一切我不知道,我不知道是哪裏的問題時,事情是,IPN監聽器插入的交易數據到ipn_data_tbl後,我想更新與相同的值$定製的記錄,但不工作,是我唯一需要的,其他的一切,但是這個工作正常,這是我的代碼:mysqli的UPDATE沒有工作,但在屏幕上

$tokens = explode("\r\n\r\n", trim($res)); 
$res = trim(end($tokens)); 
if (strcmp($res, "VERIFIED") == 0 || strcasecmp($res, "VERIFIED") == 0) { 

    //Payment data 
    $item_name = $_POST['item_name']; 
    $txn_id = $_POST['txn_id']; 
    $payment_gross = $_POST['mc_gross']; 
    $currency_code = $_POST['mc_currency']; 
    $payment_status = $_POST['payment_status']; 
    $create_date = date('Y-m-d H:i:s'); 
    $payment_date = date('Y-m-d H:i:s'); 
    $payer_email = $_POST['payer_email']; 
    $txn_type = $_POST['txn_type']; 
    $custom = $_POST['custom']; 

//Check if payment data exists with the same TXN ID. 
$prevPayment = $con->query("SELECT UID FROM ipn_data_tbl WHERE txn_id = '".$txn_id."'"); 
if($prevPayment->num_rows > 0){ 
    exit(); 
}else{ 
    //Insert tansaction data into the database 
    $insert = $con->query("INSERT INTO ipn_data_tbl(item_name,txn_id,amount,currency,payment_status,create_date,payment_date,payer_email,txn_type,UID) VALUES('".$item_name."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."','".$create_date."', '".$payment_date."','".$payer_email."','".$txn_type."','".$custom."')"); 

} 

if ($con->query($insert) === TRUE) { 

    echo $update = $con->query("UPDATE `transportation` SET `paypal_status`='$payment_status' WHERE `id`='$custom'"); 
} 
else { 
    $delete = $con->query("DELETE FROM transportation WHERE txn_id = '".$txn_id."'"); 
} 

} 
+0

在你的代碼中,你檢查PHP或MySQL錯誤嗎? – Jocelyn

+0

胡胡我很抱歉,這是我的代碼只是底部,我得到了連接文件和其他一切在開始時(使用其他文件包括) –

+0

'$服務器=「localhost」的; $ username =「myuser」; $ password =「mypassword」; $ database =「thedatabasename」; $ CON =新的mysqli($服務器,用戶名$,$密碼,$數據庫); 如果($騙局!){ 模具( '無法連接:' mysqli_connect_error($ CON)); }' –

回答

0

我很抱歉,我不得不改變的唯一的事情是這樣的:

if ($con->query($insert) === TRUE) { 

    echo $update = $con->query("UPDATE `transportation` SET `paypal_status`='$payment_status' WHERE `id`='$custom'"); 
} 
else { 
    $delete = $con->query("DELETE FROM transportation WHERE txn_id = '".$txn_id."'"); 
} 

到這裏

if ($insert) === TRUE) { 

    echo $update = $con->query("UPDATE `transportation` SET `paypal_status`='$payment_status' WHERE `id`='$custom'"); 
} 
else { 
    $delete = $con->query("DELETE FROM transportation WHERE txn_id = '".$txn_id."'"); 
} 
相關問題