PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 31, 2022

[FIXED] Error #1064 MySQL Syntax Error

 January 31, 2022     mysql, phpmyadmin     No comments   

Issue

I'm trying to import several brands into a table.

INSERT INTO fme_brands (brand_id, brand_name, brand_website, brand_address, brand_logo, brand_featured, brand_contact_name, brand_contact_phone, brand_details, identifier, brand_page_title, brand_meta_keywords, brand_meta_description, status, created_time, update_time) VALUES (141, 'Accu-Cable', 'www.americandj.com/ProductsList.aspx?Category=ACCU%20Cable', NULL, 'manufacturers/files/a/c/accu-cable.jpg', 0, NULL, NULL, NULL, 'accu-cable', 'Accu-Cable', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49');(142, 'Actasign', NULL, NULL, 'manufacturers/files/no_image_available.jpg', 0, NULL, NULL, NULL, 'actasign', 'Actasign', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49');(143, 'Adam', NULL, NULL, 'manufacturers/files/no_image_available.jpg', 0, NULL, NULL, NULL, 'adam', 'Adam', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'); (144, 'ADI', NULL, NULL, 'manufacturers/files/no_image_available.jpg', 0, NULL, NULL, NULL, 'adi', 'ADI', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'); (145, 'ADJ', 'www.adj.com', NULL, 'manufacturers/files/a/m/american-dj_1.jpg', 0, NULL, NULL, NULL, 'american-dj', 'ADJ', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'); (146, 'Adobe', NULL, NULL, 'manufacturers/files/no_image_available.jpg', 0, NULL, NULL, NULL, 'adobe', 'Adobe', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'); (147, 'Aerial7', 'www.aerial7.com', NULL, 'manufacturers/files/a/e/aerial7.jpg', 0, NULL, NULL, NULL, 'aerial7', 'Aerial7', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'); (148, 'Akai Professional', 'www.akaipro.com', NULL, 'manufacturers/files/a/k/akai.gif', 0, NULL, NULL, NULL, 'akai-professional', 'Akai Professional', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49');

While the 1st line always imports correctly, I get syntax error saying "#1064 - 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 '142, 'Actasign', NULL, NULL, 'manufacturers/files/no_image_available.jpg', 0, N "

This leads me to believe that there is a problem with the parenthesis at the beginning of each line? Anyone know where I'm going wrong?


Solution

You need comma not semicolon after each value set: e.g.

From the manual:

INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);

Your query:

INSERT INTO fme_brands (brand_id, brand_name, brand_website, brand_address, brand_logo, brand_featured, brand_contact_name, brand_contact_phone, brand_details, identifier, brand_page_title, brand_meta_keywords, brand_meta_description, status, created_time, update_time) 
VALUES 
(141, 'Accu-Cable', 'www.americandj.com/ProductsList.aspx?Category=ACCU%20Cable', NULL, 'manufacturers/files/a/c/accu-cable.jpg', 0, NULL, NULL, NULL, 'accu-cable', 'Accu-Cable', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'),
(142, 'Actasign', NULL, NULL, 'manufacturers/files/no_image_available.jpg', 0, NULL, NULL, NULL, 'actasign', 'Actasign', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'),
(143, 'Adam', NULL, NULL, 'manufacturers/files/no_image_available.jpg', 0, NULL, NULL, NULL, 'adam', 'Adam', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'),
(144, 'ADI', NULL, NULL, 'manufacturers/files/no_image_available.jpg', 0, NULL, NULL, NULL, 'adi', 'ADI', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'),
(145, 'ADJ', 'www.adj.com', NULL, 'manufacturers/files/a/m/american-dj_1.jpg', 0, NULL, NULL, NULL, 'american-dj', 'ADJ', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'),
(146, 'Adobe', NULL, NULL, 'manufacturers/files/no_image_available.jpg', 0, NULL, NULL, NULL, 'adobe', 'Adobe', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'),
(147, 'Aerial7', 'www.aerial7.com', NULL, 'manufacturers/files/a/e/aerial7.jpg', 0, NULL, NULL, NULL, 'aerial7', 'Aerial7', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49'),
(148, 'Akai Professional', 'www.akaipro.com', NULL, 'manufacturers/files/a/k/akai.gif', 0, NULL, NULL, NULL, 'akai-professional', 'Akai Professional', NULL, NULL, 1, '2015-11-17 00:01:49', '2015-11-17 00:01:49');

This is why your first value set imported in your query, because it was like the following:

INSERT INTO tbl_name (a,b,c) VALUES(1,2,3); #ok
(4,5,6),(7,8,9); #error, no INSERT INTO


Answered By - Kostas Mitsarakis
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing