我在尝试将数据保存到mysql时遇到此错误,我在这里看不到任何错误
$cons_no = $_POST['cons_no'];
$ship_name = $_POST['ship_name'];
$ship_location = $_POST['ship_location'];
$phone = $_POST['phone'];
$s_add = $_POST['s_add'];
$r_name = $_POST['r_name'];
$r_phone = $_POST['r_phone'];
$r_add = $_POST['r_add'];
$type = $_POST['type'];
$weight = $_POST['weight'];
$invoice_no = $_POST['invoice_no'];
$qty = $_POST['qty'];
$book_mode = $_POST['book_mode'];
$freight = $_POST['freight'];
$mode = $_POST['mode'];
$pick_date = $_POST['pick_date'];
$pick_time = $_POST['pick_time'];
$status = $_POST['status'];
$comments = $_POST['comments'];
$r_country = $_POST['r_country'];
唯一不在代码中的是自动增量的cid
$sql = "INSERT INTO tbl_courier (cons_no, ship_name, ship_location, phone, s_add, r_name, r_phone, r_add, type, weight, invoice_no, qty, book_mode, freight, mode, pick_date, pick_time, status, comments, r_country)
VALUES('$cons_no', '$ship_name', '$ship_location', '$phone', '$s_add', '$r_name', '$r_phone', '$r_add', '$type', '$weight', $invoice_no, '$qty', '$freight', '$mode', '$pick_date', '$pick_time', '$status', '$comments', '$r_country')";
答案 0 :(得分:1)
我不知道您构建的SQL字符串,但我可以假设您有空值..以防止您在分配值之前添加额外的检查。
$status = isset($_POST['status'])?$_POST['status']:0; // default 0 if don't exists
编辑:
我看到了您的查询,答案是:值句中缺少字段book_mode