Php 卷曲不';更新数据库
我正在尝试用脱机版本更新联机数据库。执行以下代码时不会给出错误代码,但不会显示预期结果。由于谷歌的一系列搜索被证明是失败的,任何帮助都将受到感激Php 卷曲不';更新数据库,php,curl,Php,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
<?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
}
?>
您是否尝试传递数组
$data = array('name' => 'aaa', 'title' => 'dev');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
您可能需要提供更多详细信息。例如,你是如何检查成功的?您确定源数据库中有要选择的记录吗?