我真的很沮丧,因为我不知道我的代码中的问题是什么。在我编辑之前它工作正常,我可以将数据插入数据库但是当我添加一些它突然没有工作。然后我退回原来的代码然后它已经没有工作了。你能来看看这里的问题
upload.php的
<?php
// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['agent']) && isset($_POST['days']) && isset($_POST['barcode']) && isset($_POST['client'])
&& isset($_POST['qty']) && isset($_POST['uom']) && isset($_POST['amt']) && isset($_POST['ext'])) {
$agent = $_POST['agent'];
$days = $_POST['days'];
$barcode = $_POST['barcode'];
$client = $_POST['client'];
$qty = $_POST['qty'];
$uom = $_POST['uom'];
$amt = $_POST['amt'];
$ext = $_POST['ext'];
//$date = $_POST['date'];
// include db connect class
require_once __DIR__ . '/dbconnect.php';
// connecting to db
$db = new DB_CONNECT();
// mysql update row with matched pid
$result = mysql_query("INSERT INTO salestrans (agent,days,barcode,client,qty,uom,amt,ext) values
('$agent','$days','$barcode','$client','$qty','$uom','$amt','$ext')");
// check if row inserted or not
if ($result) {
// successfully updated
$response["success"] = 1;
$response["message"] = "Product successfully uploaded.";
// echoing JSON response
echo json_encode($response);
} else {
// not successfully updated
$response["success"] = 0;
$response["message"] = "Product unsuccessfully uploaded.";
// echoing JSON response
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>