<?php
include("check_user.php");
$id_bill = $_POST['id_bill'];
$member_id = $_POST['member_id'];
$total = $_POST['total'];
$submit = $_POST['submit'];
$date = date("Y-m-d", time());
print_r($_POST);
$sql = "SELECT * FROM money_all ";
$query = mysqli_query($conn,$sql) or die ("Error Query [".$sql."]");
while($result=mysqli_fetch_array($query,MYSQLI_ASSOC)) {
$x = $result["id_bill"];
}
if (($id_bill != $x)) {
$sql ="INSERT into money_all (id_bill , member_id , date , total)
VALUES ('$id_bill' , '$member_id' , '$date' , '$total')";
$query = $conn->query($sql) or die($conn->error . "<br>$sql");
} else {
$sql = "UPDATE money_all SET
WHERE member_id='$_SESSION[login_true]' AND id_bill = '".$_POST["id_bill"]."' ";
$query = $conn->query($sql) or die($conn->error . "<br>$sql");
exit();
}
?>
จากโค้ดด้านบนผมทำแล้วมี error แบบนี้ครับ You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near Code (PHP)
Array ( [submit] => พิมพ์ใบเสร็จแบบ A4 [member_id] => admin [id_bill] => 371 [total] => 2020 [date] => 2018-07-25 ) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE member_id='admin' AND id_bill = '371'' at line 2
UPDATE money_all SET WHERE member_id='admin' AND id_bill = '371