ช่วยแก้ error คำสั่ง insert เข้าดาต้าเบส ให้หน่อยค่ะ
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 ')VALUES ('BP1103-001','31-3-2011','14:41:22','1','No','1234','5678','','a123','5' at line 1
มันหมายความว่ายังไงคะ แล้วต้องแก้แบบไหนคะ โค๊ดตามนี้ค่ะ
Code (PHP)
$num_inv = count($inv_id);
if($num_inv > 0){
$arr_inv = array_values ($inv_id);
$id = "";
for($i=0; $i<$num_inv; $i++){
$update_tax = "update room set Arri_val ='".$Arrival[$arr_inv[$i]]."', Price_S ='".$PriceS[$arr_inv[$i]]."' where No = '".$arr_inv[$i]."'";
//echo "update room set Arri_val ='".$Arrival[$arr_inv[$i]]."', Price_S ='".$PriceS[$arr_inv[$i]]."' where No = '".$arr_inv[$i]."'";
mysql_query($update_tax);
$id .= $arr_inv[$i];
if($i != ($num_inv -1)){ $id .= ",";};
}
}
if($id != ''){
$billstr = "BP".date("ym");
$check_suffix = mysql_query("select CHECKIN_ID from checkin where CHECKIN_ID like '".$billstr."%' order by CHECKIN_ID desc limit 1") or die (mysql_error());
$num = mysql_fetch_row($check_suffix);
$strnum = explode("-",$num[0]);
$lastdigit = explode("00",$strnum[1]);
$credit = $_POST["credit"];
$autonum = $lastdigit[1]+1;
$bill_no = $billstr."-00".$autonum;
mysql_query("update room set Status = '2', cus_id = '$cusno', bill_no = '$bill_no' where No in (".$id.")") or die (mysql_error());
$getdate = explode(" ",$chdate);
$date_ =$getdate[0];
$time = $getdate[1];
$strSQL = "INSERT INTO checkin ";
$strSQL .="(Bill_no, Date, Time, Cus_ID, Receipt, Food_cp1, Food_cp2, Food_cp3,Internet_c1, Price_in1, Internet_c2, Price_in2, Internet_c3, Price_in3, Internet_c4, Price_in4, Internet_c5, Price_in5,)";
$strSQL .="VALUES ";
$strSQL .="('".$bill_no."','".$date_."','".$time."','".$cusno."','".$Receipt."','".$food_coupons1."','".$food_coupons2."','".$food_coupons3."','".$internet_card1."','".$price_in1."','".$internet_card2."','".$price_in2."','".$internet_card3."','".$price_in3."','".$internet_card4."','".$price_in4."','".$internet_card5."','".$price_in5."'); ";
mysql_query($strSQL) or die (mysql_error());
}
$checkinlist = mysql_query("select * from room where bill_no = '".$bill_no."'") or die (mysql_error());
คำสั่งที่ error จะเป็นคำสั่ง insert ของ $strSQL ค่ะ ไม่ทราบต้องแก้แบบไหนคะ
ดาต้าเบสตามนี้ค่ะ
CHECKIN_ID int(11)
Bill_no varchar(50)
Date date
Time time
Cus_ID int(11)
Receipt varchar(10)
Food_cp1 varchar(150)
Food_cp2 varchar(150)
Food_cp3 varchar(150)
Internet_c1 varchar(150)
Price_in1 varchar(150)
Internet_c2 varchar(150)
Price_in2 varchar(150)
Internet_c3 varchar(150)
Price_in3 varchar(150)
Internet_c4 varchar(150)
Price_in4 varchar(150)
Internet_c5 varchar(150)
Price_in5 varchar(150)
Pay varchar(150)
Cash varchar(150)
Trace_Card varchar(150)
Batch_Card varchar(150)
Namepays varchar(255)
Recipients varchar(150)Tag : PHP, MySQL
ประวัติการแก้ไข 2011-03-31 14:57:53
Date :
2011-03-31 14:53:35
By :
aobjung
View :
717
Reply :
2
ขอบคุณมากเลยค่ะพี่วิน หาตั้งนาน _/|\_
Date :
2011-03-31 16:58:36
By :
aobjung
Load balance : Server 04