 |
insert เข้า database ไม่ได้ echo ออกปกติ แต่ไม่เข้าไปเก็บใน sql |
|
 |
|
|
 |
 |
|
Code (PHP)
include 'config.php';
$q = "select * from product_cart where member_id = '".$_SESSION["num_sum"]."'";
$w = mysql_query($q);
while ($z = mysql_fetch_array($w))
{
$cart = $z['pcart_name'];
$cart2 = $z['pcart_qty'];
$cart3 = $z['pcart_price'];
$a = "INSERT INTO order ";
$a .="(order_bill,order_date,member_id,pcart_name,pcart_qty,pcart_price,order_payment,order_status) ";
$a .="VALUES ";
$a .="('".$_SESSION['bill']."','".$_SESSION['date']."','".$_SESSION['id']."','".$cart."','".$cart2."','".$cart3."','".$_POST['select']."',1) ";
$b = mysql_query($a);
}
ในที่นี้ข้อมูลในตาราง Product_cart ที่ select ออกมาได้ ได้จำนวน 3 แถว ผมลอง echo $a แสดงออกปกติครับ
แต่มันไม่ Insert ลงใน ตาราง Order ให้ ไม่ทราบว่าต้องแก้ไขอย่างไรครับ ขอบคุณครับ
Tag : PHP, MySQL, HTML/CSS, JavaScript, jQuery, JAVA
|
ประวัติการแก้ไข 2016-09-12 15:47:56 2016-09-12 15:48:54 2016-09-12 15:49:18
|
 |
 |
 |
 |
Date :
2016-09-12 15:44:51 |
By :
zezemoz |
View :
803 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันมี error แจ้งเตือนมั้ยครับ
|
 |
 |
 |
 |
Date :
2016-09-12 15:59:18 |
By :
stepartz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$a = "INSERT INTO 'order' ";
$a .="('order_bill','order_date','member_id','pcart_name','pcart_qty','pcart_price','order_payment','order_status') ";
ลองแบบนี้ดูครับ
|
 |
 |
 |
 |
Date :
2016-09-12 16:09:55 |
By :
stepartz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะเกี่ยวกับ "คำสงวน" คือ order เป็นคำสงวนในคำสั่ง SQL ถ้าจะใช้ตั้งชื่อฟิลด์ ชื่อตารางควรเพิ่มอักษรอื่นเข้าไปด้วย เช่น tbl_order, orders, order_detail, ... ครับ
|
 |
 |
 |
 |
Date :
2016-09-12 17:38:01 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
reserved words order
|
 |
 |
 |
 |
Date :
2016-09-13 12:59:44 |
By :
fossil31 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
วิธีแก้ให้ใส่ backquote ครอบ `order`
backquote ไม่ใช่ single quote
|
 |
 |
 |
 |
Date :
2016-09-13 13:46:24 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|