MySQL错误:1064(您的SQL语法中有错误;请查看与您的MySQL服务器版本对应的手册,以便在#39;附近使用正确的语法)'在第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'] . "', "
. " )";
无效的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 :(得分: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'] . "' " . " )";
答案 1 :(得分: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'] . "' " . " )";