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 'INSERT INTO ******_sports_teams (******_team_id,
******_content_type_id, ******' at line 2
That is the error I get to this script;
The stars cover the name of the company I work for that I cannot release, but they are all the same word that I know is spelled correctly.
SELECT * FROM `******_sports_teams` WHERE 1
INSERT INTO ******_sports_teams
(******_team_id, ******_content_type_id, ******_content_type_desc,
******_sport_name, ******_sport_confernece, ******_sport_division,
******_sport_city, ******_sport_team)
VALUES
(1,4,'Sports','NBA','Eastern','Atlantic','Boston','Celtics'),
(2,4,'Sports','NBA','Eastern','Atlantic','Brooklyn','Nets'),
(3,4,'Sports','NBA','Eastern','Atlantic','Newy York','Knicks'),
(4,4,'Sports','NBA','Eastern','Atlantic','Philedelphia','76ers'),
(5,4,'Sports','NBA','Eastern','Atlantic','Toronto','Raptors'),
(6,4,'Sports','NBA','Eastern','Central','Chicago','Bulls'),
(7,4,'Sports','NBA','Eastern','Central','Cleveland','Cavaliers'),
(8,4,'Sports','NBA','Eastern','Central','Detriot','Pistons'),
(9,4,'Sports','NBA','Eastern','Central','Indiana','Pacers'),
(10,4,'Sports','NBA','Eastern','Central','Milwaukee','Bucks'),
(11,4,'Sports','NBA','Eastern','Southeast','Atlanta','Hawks'),
(12,4,'Sports','NBA','Eastern','Southeast','Charlotte','Hornets'),
(13,4,'Sports','NBA','Eastern','Southeast','Miami','Heat'),
(14,4,'Sports','NBA','Eastern','Southeast','Orlando','Magic'),
(15,4,'Sports','NBA','Eastern','Southeast','Washington','Wizards'),
(16,4,'Sports','NBA','Western','Southwest','Dallas','Mavericks'),
(17,4,'Sports','NBA','Western','Southwest','Houston','Rockets'),
(18,4,'Sports','NBA','Western','Southwest','Memphis','Grizzlies'),
(19,4,'Sports','NBA','Western','Southwest','New Orleans','Pelicans'),
(20,4,'Sports','NBA','Western','Southwest','San Antonio','Spurs'),
(21,4,'Sports','NBA','Western','Northwest','Denver','Nuggets'),
(22,4,'Sports','NBA','Western','Northwest','Minnesota','Timber Wolves'),
(23,4,'Sports','NBA','Western','Northwest','Oaklohoma City','Thunder'),
(24,4,'Sports','NBA','Western','Northwest','Portland','Trail Blazers'),
(25,4,'Sports','NBA','Western','Northwest','Utah','Jazz'),
(26,4,'Sports','NBA','Western','Pacific','Golden State','Warriors'),
(27,4,'Sports','NBA','Western','Pacific','Los Ageles','Clippers'),
(28,4,'Sports','NBA','Western','Pacific','Los Ageles','Lakers'),
(29,4,'Sports','NBA','Western','Pacific','Pheonix','Suns'),
(30,4,'Sports','NBA','Western','Pacific','Sacremento','Kings'),
(31,4,'Sports','MLB','American','East','Tampa Bay','Rays'),
(32,4,'Sports','MLB','American','East','New York','Yankees'),
(33,4,'Sports','MLB','American','East','Baltimore','Orioles'),
(34,4,'Sports','MLB','American','East','Toronto','Blue Jays'),
(35,4,'Sports','MLB','American','East','Boston','Red Socks'),
(36,4,'Sports','MLB','American','Central','Kansas City','Royals'),
(37,4,'Sports','MLB','American','Central','Minnesota','Twins'),
(38,4,'Sports','MLB','American','Central','Detriot','Tigers'),
(39,4,'Sports','MLB','American','Central','Cleveland','Indians'),
(40,4,'Sports','MLB','American','Central','Chicago','White Sox'),
(41,4,'Sports','MLB','American','West','Houston','Astros'),
(42,4,'Sports','MLB','American','West','Texas','Rangers'),
(43,4,'Sports','MLB','American','West','Los Ageles','Angels'),
(44,4,'Sports','MLB','American','West','Seattle','Mariners'),
(45,4,'Sports','MLB','American','West','Oakland','Athletics'),
(46,4,'Sports','MLB','National','East','New York','Mets'),
(47,4,'Sports','MLB','National','East','Washington','Nationals').
(48,4,'Sports','MLB','National','East','Atlanta','Braves'),
(49,4,'Sports','MLB','National','East','Philedelphia','Phillies'),
(50,4,'Sports','MLB','National','East','Miami','Marlins'),
(51,4,'Sports','MLB','National','Central','St. Louis','Cardinals'),
(52,4,'Sports','MLB','National','Central','Pittsburg','Pirates'),
(53,4,'Sports','MLB','National','Central','Chicago','Cubs'),
(54,4,'Sports','MLB','National','Central','Cincinnati','Reds'),
(55,4,'Sports','MLB','National','Central','Milwaukee','Brewers'),
(56,4,'Sports','MLB','National','West','Los Ageles','Dodgers'),
(57,4,'Sports','MLB','National','West','San Francisco','Giants'),
(58,4,'Sports','MLB','National','West','Arizona','Diamondbacks'),
(59,4,'Sports','MLB','National','West','San Diego','Padres'),
(60,4,'Sports','MLB','National','West','Colorado','Rockies'),
(61,4,'Sports','NFL','NFC','East','Dallas','Cowboys'),
(62,4,'Sports','NFL','NFC','East','New York','Giants'),
(63,4,'Sports','NFL','NFC','East','Philedelphia','Eagles'),
(64,4,'Sports','NFL','NFC','East','Washington','Redskins'),
(65,4,'Sports','NFL','NFC','West','Arizona','Cardinals'),
(66,4,'Sports','NFL','NFC','West','San Francisco','49ers'),
(67,4,'Sports','NFL','NFC','West','Seattle','Seahawks'),
(68,4,'Sports','NFL','NFC','West','St. Louis','Rams'),
(69,4,'Sports','NFL','NFC','North','Chicago','Bears'),
(70,4,'Sports','NFL','NFC','North' ,'Detriot','Lions'),
(71,4,'Sports','NFL','NFC','North' ,'Green Bay','Packers'),
(72,4,'Sports','NFL','NFC','North' ,'Minnesota','Vikings'),
(73,4,'Sports','NFL','NFC','South','Atlanta','Falcons'),
(74,4,'Sports','NFL','NFC','South', 'Carolina','Panthers'),
(75,4,'Sports','NFL','NFC','South','New Orleans','Saints'),
(76,4,'Sports','NFL','NFC','South','Tampa Bay','Buccaneers'),
(77,4,'Sports','NFL','AFC','East','Buffalo','Bills'),
(78,4,'Sports','NFL','AFC','East','Miami','Dolphins'),
(79,4,'Sports','NFL','AFC','East','New England','Patriots'),
(80,4,'Sports','NFL','AFC','East','New York','Jets'),
(81,4,'Sports','NFL','AFC','West','Denver','Broncos'),
(82,4,'Sports','NFL','AFC','West','Kansas City','Chiefs'),
(83,4,'Sports','NFL','AFC','West','Oakland','Raiders'),
(84,4,'Sports','NFL','AFC','West','San Diego','Chargers'),
(85,4,'Sports','NFL','AFC','North' ,'Baltimore','Ravens'),
(86,4,'Sports','NFL','AFC','North' ,'Cleveland','Browns'),
(87,4,'Sports','NFL','AFC','North','Pittsburg','Steelers'),
(88,4,'Sports','NFL','AFC','North' ,'Cincinnati','Bengals'),
(89,4,'Sports','NFL','AFC','South','Houston','Texans'),
(90,4,'Sports','NFL','AFC','South','Indianapolis','Colts'),
(91,4,'Sports','NFL','AFC','South','Jacksonville','Jaguars'),
(92,4,'Sports','NFL','AFC','South','Tennessee','Titans'),
(93,4,'Sports','NHL','NHL','Central','Chicago','Blackhawks'),
(94,4,'Sports','NHL','NHL','Central','Colorado','Avalanche'),
(95,4,'Sports','NHL','NHL','Central','Dallas','Stars'),
(96,4,'Sports','NHL','NHL','Central','Minnesota','Wild'),
(97,4,'Sports','NHL','NHL','Central','St. Louis','Blues'),
(98,4,'Sports','NHL','NHL','Central','Winnipeg','Jets'),
(99,4,'Sports','NHL','NHL','Central','Nashville','Predators'),
(100,4,'Sports','NHL','NHL','Pacific','Anaheim' ,'Ducks'),
(101,4,'Sports','NHL','NHL','Pacific','Arizona','Coyotes'),
(102,4,'Sports','NHL','NHL','Pacific','Clagary','Flames'),
(103,4,'Sports','NHL','NHL','Pacific','Edmonton','Oilers'),
(104,4,'Sports','NHL','NHL','Pacific','Los Ageles','Kings'),
(105,4,'Sports','NHL','NHL','Pacific','San Jose','Sharks'),
(106,4,'Sports','NHL','NHL','Pacific','Vancouver','Canucks'),
(107,4,'Sports','NHL','NHL','Atlantic','Boston','Bruins'),
(108,4,'Sports','NHL','NHL','Atlantic','Buffalo','Sabres'),
(109,4,'Sports','NHL','NHL','Atlantic','Detriot','Red Wings'),
(110,4,'Sports','NHL','NHL','Atlantic','Florida','Panthers'),
(111,4,'Sports','NHL','NHL','Atlantic','Montreal','Canadiens'),
(112,4,'Sports','NHL','NHL','Atlantic','Ottawa','Senators'),
(113,4,'Sports','NHL','NHL','Atlantic','Tampa Bay','Lightning'),
(114,4,'Sports','NHL','NHL','Atlantic','Toronto','Maple Leafs'),
(115,4,'Sports','NHL','NHL','Metropolitan','Corolina','Hurricanes'),
(116,4,'Sports','NHL','NHL','Metropolitan','Columbus','Blue Jackets'),
(117,4,'Sports','NHL','NHL','Metropolitan','New Jersey','Devils'),
(118,4,'Sports','NHL','NHL','Metropolitan','New York','Islanders'),
(119,4,'Sports','NHL','NHL','Metropolitan','New York','Rangers'),
(120,4,'Sports','NHL','NHL','Metropolitan','Philedelphia','Flyers'),
(121,4,'Sports','NHL','NHL','Metropolitan','Pittsburg','Penguins'),
(122,4,'Sports','NHL','NHL','Metropolitan','Washington','Capitals')
you have a dot (.) instead of a comma (,) at the end of the line with ID 47:
(47,4,'Sports','MLB','National','East','Washington','Nationals').
Change it to
(47,4,'Sports','MLB','National','East','Washington','Nationals'),
You have a period at the end of this line:
(47,4,'Sports','MLB','National','East','Washington','Nationals').
It should be a comma
Your error message show us, that two queries does not separated with ;
Just remove Select query, or add ; after it.
Then, double check syntax, or read next error message. You have points instead of comma somewhere.
Your first query retrieve all data from the table. It's:
SELECT * FROM `******_sports_teams` WHERE 1
It should terminated with semicolon before you call next (INSERT) query
$query = "
INSERT INTO rets_property_res (ACREAGE, BATHS_FULL, BATHS_HALF, BEDROOMS, CATEGORY, CITY, COUNTY, CO_LA_CODE, CO_LO_CODE, CURRENT_PRICE, DATE_MODIFIED, DIRECTIONS, ELEM_SCHOOL, FTR_APPLIANCE, FTR_CONSTRC_STATUS, FTR_CONSTRUC, FTR_COOLING, FTR_DESIGN, FTR_DININGTYPE, FTR_ENERGY, FTR_EXTERIOR, FTR_FACILITY, FTR_FLOORS, FTR_HEATING, FTR_INTERIOR, FTR_INTERNET, FTR_LOTDESC, FTR_MSTR_BATH_DESC, FTR_MSTR_BDRM_DESC, FTR_PARKING, FTR_POOL, FTR_ROOF, FTR_SIDING, FTR_SPECIAL_SALE_TYPE, FTR_STYLE, FTR_WATERFRONT, FTR_WATERVIEW, HIGH_SCHOOL, INTERMEDIATE_SCHOOL, LA_CODE, LIST_DATE, LIST_PRICE, LOT_DIMENSIONS, LO_CODE, MEDIA_FLAG, MIDDLE_SCHOOL, MLS_ACCT, PHOTO_COUNT, PHOTO_DATE_MODIFIED, PROJ_NAME, PROP_TYPE, REMARKS, STATE, STATUS, STREET_DIR, STREET_NAME, STREET_NUM, SUBDIVISION, TOT_HEAT_SQFT, UNIT_NUM, VT_YN, YEAR_BUILT, ZIP)
VALUES (\"$listing[ACREAGE]\", \"$listing[BATHS_FULL]\", \"$listing[BATHS_HALF]\", \"$listing[BEDROOMS]\", \"$listing[CATEGORY]\", \"$listing[CITY]\", \"$listing[COUNTY]\", \"$listing[CO_LA_CODE]\", \"$listing[CO_LO_CODE]\", \"$listing[CURRENT_PRICE]\", \"$listing[DATE_MODIFIED]\", \"$listing[DIRECTIONS]\", \"$listing[ELEM_SCHOOL]\", \"$listing[FTR_APPLIANCE]\", \"$listing[FTR_CONSTRC_STATUS]\", \"$listing[FTR_CONSTRUC]\", \"$listing[FTR_COOLING]\", \"$listing[FTR_DESIGN]\", \"$listing[FTR_DININGTYPE]\", \"$listing[FTR_ENERGY]\", \"$listing[FTR_EXTERIOR]\", \"$listing[FTR_FACILITY]\", \"$listing[FTR_FLOORS]\", \"$listing[FTR_HEATING]\", \"$listing[FTR_INTERIOR]\", \"$listing[FTR_INTERNET]\", \"$listing[FTR_LOTDESC]\", \"$listing[FTR_MSTR_BATH_DESC]\", \"$listing[FTR_MSTR_BDRM_DESC]\", \"$listing[FTR_PARKING]\", \"$listing[FTR_POOL]\", \"$listing[FTR_ROOF]\", \"$listing[FTR_SIDING]\", \"$listing[FTR_SPECIAL_SALE_TYPE]\", \"$listing[FTR_STYLE]\", \"$listing[FTR_WATERFRONT]\", \"$listing[FTR_WATERVIEW]\", \"$listing[HIGH_SCHOOL]\", \"$listing[INTERMEDIATE_SCHOOL]\", \"$listing[LA_CODE]\", \"$listing[LIST_DATE]\", \"$listing[LIST_PRICE]\", \"$listing[LOT_DIMENSIONS]\", \"$listing[LO_CODE]\", \"$listing[MEDIA_FLAG]\", \"$listing[MIDDLE_SCHOOL]\", \"$listing[MLS_ACCT]\", \"$listing[PHOTO_COUNT]\", \"$listing[PHOTO_DATE_MODIFIED]\", \"$listing[PROJ_NAME]\", \"$listing[PROP_TYPE]\", \"$listing[REMARKS]\", \"$listing[STATE]\", \"$listing[STATUS]\", \"$listing[STREET_DIR]\", \"$listing[STREET_NAME]\", \"$listing[STREET_NUM]\", \"$listing[SUBDIVISION]\", \"$listing[TOT_HEAT_SQFT]\", \"$listing[UNIT_NUM]\", \"$listing[VT_YN]\", \"$listing[YEAR_BUILT]\", \"$listing[ZIP]\")";
$result = mysql_query($query);
I get this error:
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 'television above your gas fireplace or enjoying your view of the Bay. Then open' at line 2
I can't find the error. I have been looking for like 2 hrs. What is spilled out as an "error" is from the REMARKS field. There isn't a syntax error though.
Try this:
$query = "
INSERT INTO rets_property_res (ACREAGE, BATHS_FULL, BATHS_HALF, BEDROOMS, CATEGORY, CITY, COUNTY, CO_LA_CODE, CO_LO_CODE, CURRENT_PRICE, DATE_MODIFIED, DIRECTIONS, ELEM_SCHOOL, FTR_APPLIANCE, FTR_CONSTRC_STATUS, FTR_CONSTRUC, FTR_COOLING, FTR_DESIGN, FTR_DININGTYPE, FTR_ENERGY, FTR_EXTERIOR, FTR_FACILITY, FTR_FLOORS, FTR_HEATING, FTR_INTERIOR, FTR_INTERNET, FTR_LOTDESC, FTR_MSTR_BATH_DESC, FTR_MSTR_BDRM_DESC, FTR_PARKING, FTR_POOL, FTR_ROOF, FTR_SIDING, FTR_SPECIAL_SALE_TYPE, FTR_STYLE, FTR_WATERFRONT, FTR_WATERVIEW, HIGH_SCHOOL, INTERMEDIATE_SCHOOL, LA_CODE, LIST_DATE, LIST_PRICE, LOT_DIMENSIONS, LO_CODE, MEDIA_FLAG, MIDDLE_SCHOOL, MLS_ACCT, PHOTO_COUNT, PHOTO_DATE_MODIFIED, PROJ_NAME, PROP_TYPE, REMARKS, STATE, STATUS, STREET_DIR, STREET_NAME, STREET_NUM, SUBDIVISION, TOT_HEAT_SQFT, UNIT_NUM, VT_YN, YEAR_BUILT, ZIP)
VALUES (
'".mysql_real_escape_string($listing['ACREAGE'])."',
'".mysql_real_escape_string($listing['BATHS_FULL'])."', '".mysql_real_escape_string($listing['BATHS_HALF'])."', '".mysql_real_escape_string($listing['BEDROOMS'])."', '".mysql_real_escape_string($listing['CATEGORY'])."', '".mysql_real_escape_string($listing['CITY'])."', '".mysql_real_escape_string($listing['COUNTY'])."', '".mysql_real_escape_string($listing['CO_LA_CODE'])."', '".mysql_real_escape_string($listing['CO_LO_CODE'])."', '".mysql_real_escape_string($listing['CURRENT_PRICE'])."', '".mysql_real_escape_string($listing['DATE_MODIFIED'])."', '".mysql_real_escape_string($listing['DIRECTIONS'])."', '".mysql_real_escape_string($listing['ELEM_SCHOOL'])."', '".mysql_real_escape_string($listing['FTR_APPLIANCE'])."', '".mysql_real_escape_string($listing['FTR_CONSTRC_STATUS'])."', '".mysql_real_escape_string($listing['FTR_CONSTRUC'])."', '".mysql_real_escape_string($listing['FTR_COOLING'])."', '".mysql_real_escape_string($listing['FTR_DESIGN'])."', '".mysql_real_escape_string($listing['FTR_DININGTYPE'])."', '".mysql_real_escape_string($listing['FTR_ENERGY'])."', '".mysql_real_escape_string($listing['FTR_EXTERIOR'])."', '".mysql_real_escape_string($listing['FTR_FACILITY'])."', '".mysql_real_escape_string($listing['FTR_FLOORS'])."', '".mysql_real_escape_string($listing['FTR_HEATING'])."', '".mysql_real_escape_string($listing['FTR_INTERIOR'])."', '".mysql_real_escape_string($listing['FTR_INTERNET'])."', '".mysql_real_escape_string($listing['FTR_LOTDESC'])."', '".mysql_real_escape_string($listing['FTR_MSTR_BATH_DESC'])."', '".mysql_real_escape_string($listing['FTR_MSTR_BDRM_DESC'])."', '".mysql_real_escape_string($listing['FTR_PARKING'])."', '".mysql_real_escape_string($listing['FTR_POOL'])."', '".mysql_real_escape_string($listing['FTR_ROOF'])."', '".mysql_real_escape_string($listing['FTR_SIDING'])."', '".mysql_real_escape_string($listing['FTR_SPECIAL_SALE_TYPE'])."', '".mysql_real_escape_string($listing['FTR_STYLE'])."', '".mysql_real_escape_string($listing['FTR_WATERFRONT'])."', '".mysql_real_escape_string($listing['FTR_WATERVIEW'])."', '".mysql_real_escape_string($listing['HIGH_SCHOOL'])."', '".mysql_real_escape_string($listing['INTERMEDIATE_SCHOOL'])."', '".mysql_real_escape_string($listing['LA_CODE'])."', '".mysql_real_escape_string($listing['LIST_DATE'])."', '".mysql_real_escape_string($listing['LIST_PRICE'])."', '".mysql_real_escape_string($listing['LOT_DIMENSIONS'])."', '".mysql_real_escape_string($listing['LO_CODE'])."', '".mysql_real_escape_string($listing['MEDIA_FLAG'])."', '".mysql_real_escape_string($listing['MIDDLE_SCHOOL'])."', '".mysql_real_escape_string($listing['MLS_ACCT'])."', '".mysql_real_escape_string($listing['PHOTO_COUNT'])."', '".mysql_real_escape_string($listing['PHOTO_DATE_MODIFIED'])."', '".mysql_real_escape_string($listing['PROJ_NAME'])."', '".mysql_real_escape_string($listing['PROP_TYPE'])."', '".mysql_real_escape_string($listing['REMARKS'])."', '".mysql_real_escape_string($listing['STATE'])."', '".mysql_real_escape_string($listing['STATUS'])."', '".mysql_real_escape_string($listing['STREET_DIR'])."', '".mysql_real_escape_string($listing['STREET_NAME'])."', '".mysql_real_escape_string($listing['STREET_NUM'])."', '".mysql_real_escape_string($listing['SUBDIVISION'])."', '".mysql_real_escape_string($listing['TOT_HEAT_SQFT'])."', '".mysql_real_escape_string($listing['UNIT_NUM'])."', '".mysql_real_escape_string($listing['VT_YN'])."', '".mysql_real_escape_string($listing['YEAR_BUILT'])."', '".mysql_real_escape_string($listing['ZIP'])."')";
$result = mysql_query($query);
Note that this is not the best way to do it and you should use MySQLi/PDO for a more secure solution.
To be honest.. it is very hard to debug like this. There could be a chance that in REMARKS field, you have un-escaped double quote or other characters that break the query compiling. Have you tried to insert a small amount of data first?
I will suggest inserting a 'hello world' first before going crazy with this kind of insert.
I also suggest using single quote like '$listing[REMARKS]' as the default mysql syntax.