2014-11-05 59 views
-3

MySQL錯誤:1064(您的SQL語法中有錯誤;請檢查與您的MySQL服務器版本對應的手冊在第1行附近')'使用正確的語法) 會話暫停。MySQL錯誤:1064(您在SQL語法中有錯誤;請檢查與您的MySQL對應的手冊

$sql = "INSERT INTO ". GALLERY_MASTER 
      . "(gallery_title,gallery_code, gallery_images,gallerycat_id, gallery_description,gallery_status) " 
      . " VALUES (" 
      . " '". $post['gallery_title']    .  "', " 
      . " '". $post['gallery_code']    .  "', " 
      . " '". $file       .  "', " 
      . " '". $post['gallery_cat_id']   .  "', " 
      . " '". $post['gallery_description']  .  "', " 
      . " '". $post['gallery_status']   .  "', " 
      . ")"; 

無效的SQL:

INSERT INTO 
GALLERY_MASTER(gallery_title,gallery_code, gallery_images,gallerycat_id, gallery_description,gallery_status) 

VALUES ('image1', '021', '201411050700381463949438_img3.jpg', '4', '', '1',) 
+0

刪除最後一個,之前) – Matteo 2014-11-05 08:20:11

+0

@ Niraj7878您發佈之前格式化代碼,適當地標記到您的DBMS。 – 2014-11-05 08:20:31

回答

0

基於錯誤消息,問題是到底額外的逗號,需要用將其刪除右括號

Invalid SQL: INSERT INTO GALLERY_MASTER(gallery_title,gallery_code, gallery_images,gallerycat_id, gallery_description,gallery_status) 

VALUES ('image1', '021', '201411050700381463949438_img3.jpg', '4', '', '1',) 
---------------------------------------------------------------------------^ 

前代碼如下

$sql = "INSERT INTO ". GALLERY_MASTER . "(gallery_title,gallery_code, gallery_images,gallerycat_id, gallery_description,gallery_status) " . " VALUES (" . " '". $post['gallery_title'] . "', " . " '". $post['gallery_code'] . "', " . " '". $file . "', " . " '". $post['gallery_cat_id'] . "', " . " '". $post['gallery_description'] . "', " . " '". $post['gallery_status'] . "' " . ")"; 
0

在查詢結束時您還有一個額外的,

拷貝代碼

$sql = "INSERT INTO " . GALLERY_MASTER . "(gallery_title,gallery_code, gallery_images,gallerycat_id, gallery_description,gallery_status) " . " VALUES (" . " '" . $post['gallery_title'] . "', " . " '" . $post['gallery_code'] . "', " . " '" . $file . "', " . " '" . $post['gallery_cat_id'] . "', " . " '" . $post['gallery_description'] . "', " . " '" . $post['gallery_status'] . "' " . ")"; 
+0

謝謝you.query插入 – Niraj7878 2014-11-05 08:27:23

相關問題