我自己寫了一個api假設叫做sql.php
我在另一頁 sql-test.php
$data = array(
"errno" => '1',
"errstr" => '2',
"errfile" => '3',
"errline" => '4'
);
$data_string = json_encode($data);
$data = httpRequest($api_sql, $data_string);
httpRequest 是
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
我是丟json過去sql.php,而且是POST但是我的sql.php要怎麼寫才能接到?
sql.php有一段是
(addtime, errno, errstr, errfile, errline)
VALUES
('".time()."', '".$_POST['errno']."', '".$_POST['errstr']."', '".$_POST['errfile']."', '".$_POST['errline']."')
結果資料庫只有收到時間 time()其他四個欄位的值都沒有收到 (1234)sql.php這邊要怎麼寫才對?才能收到來自 sql-test.php 的值?
- 1 回答
- 0 关注
- 371 浏览
添加回答
举报
0/150
提交
取消