0
我正嘗試使用脫機版本更新我的聯機數據庫。下面的代碼在沒有提供錯誤代碼的情況下執行,但沒有顯示預期的結果。任何幫助將真正讚賞,因爲谷歌搜索系列證明是失敗的。Curl不更新數據庫
<?php
include("inc_files/inventory.php");
// update sales_rec records
$get_sales_rec = mysql_query("SELECT * FROM sales_rec WHERE status = '0' ORDER BY id ASC") or die(mysql_error());
while($rec = mysql_fetch_array($get_sales_rec)){
$id = $rec['id'];
$receipt = $rec['receipt'];
$customer = $rec['customer'];
$total = $rec['total'];
$amount = $rec['amount'];
$balance = $rec['balance'];
$discount = $rec['discount'];
$date = $rec['date'];
$time = $rec['time'];
? $type = "sales_rec";
$ch = curl_init(); // initiate curl
$url = "http://www.sample.com/inventory/test.php"; // where you want to post data
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true); // tell curl you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS, "type=$type&r=$receipt&c=$customer&t=$total&a=$amount&b=$balance&d=$discount&dt=$date&ti=$time"); // define what you want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format
$output = curl_exec ($ch); // execute
curl_close ($ch); // close curl handle
}
?>
您可能需要提供更多的細節。例如,你如何檢查成功?您確定在源數據庫中有要選擇的記錄嗎? – APC