简体   繁体   English

卷毛不更新数据库

[英]Curl doesn't update database

I am trying to update my online database with the offline version. 我正在尝试使用脱机版本更新在线数据库。 The following code executes without giving an error code but the expected result is not showing. 以下代码执行时未给出错误代码,但未显示预期结果。 Any help will be really appreciated as series of Google searching proved abortive. 由于Google搜索系列证明是失败的,任何帮助将不胜感激。

 <?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
  }
 ?>

have you tried passing an array 您是否尝试过传递数组

$data = array('name' => 'aaa', 'title' => 'dev');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM