我在UPDATE SQL中遇到问题,我知道在Google或堆栈溢出这里有很多答案,但是伙计们。帮帮我,我是新手,所以请放轻松。谢谢。
我正在使用最新版本的PHP,并且尝试了任何格式的UPDATE查询,但没有任何帮助。
我在这里遇到了一些问题,结果出在我的else语句中:
<?php
if(isset($_POST['m1_date'])) {
$m2date = $_POST['m1_date'];
$m2gpno = $_POST['m1_gpno'];
$m2from = $_POST['m1_from'];
$m2dest = $_POST['m1_destination'];
$m2desc = $_POST['m1_desc'];
$m2brnd = $_POST['m1_brand'];
$m2partno = $_POST['m1_partno'];
$m2sn = $_POST['m1_sn'];
$m2qty = $_POST['m1_qty'];
$m2um = $_POST['m1_um'];
$m2prpse = $_POST['m1_purpose'];
$m2rmrks = $_POST['m1_remarks'];
$sql = 'UPDATE tbl_m1gpperm_trnsfer SET m1_date = :m2date, m1_gpno = :m2gpno, m1_from = :m2from, m1_destination = :m2dest, m1_desc = :m2desc, m1_brand = :m2brnd, m1_partno = :m2partno, m1_sn = :m2sn, m1_qty = :m2qty, m1_um = :m2um, m1_purpose = :m2prpse, m1_remarks = :m2rmrks';
$stmt = $conn->prepare($sql);
if($stmt->execute([':m2date' => $m2date, ':m2gpno' => $m2gpno, ':m2from' => $m2from, ':m2dest' => $m2dest, ':m2desc' => $m2desc, ':m2brnd' => $m2brnd, ':m2partno' => $m2partno, ':m2sn' => $m2sn, ':m2qty' => $m2qty, ':m2um' => $m2um, ':m2prpse' => $m2prpse, ':m2rmrks' => $m2rmrks])) {
echo "Data has been Updated!";
header("location:/aac_admin/M2.php");
} else {
echo "Error Update!";
header("location:/aac_admin/M2.php");
}
} else {
echo "Error Data!";
}
这是“错误数据!”