mysql syntax error - Load data

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
aussie_clint
Forum Commoner
Posts: 41
Joined: Mon Jul 31, 2006 9:14 am
Location: Brisbane, Australia
Contact:

mysql syntax error - Load data

Post by aussie_clint »

i cant seem to find where i'm going wrong with my syntax

can someone see what iv don

thanks

Code: Select all

LOAD DATA LOCAL INFILE '/home/computer/public_html/cwpriceCSV.csv'
INTO TABLE `newprice list`
FIELDS TERMINATED BY `,`
LINES TERMINATED BY `\n`
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What error are you getting?
aussie_clint
Forum Commoner
Posts: 41
Joined: Mon Jul 31, 2006 9:14 am
Location: Brisbane, Australia
Contact:

Post by aussie_clint »

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 ',`
LINES TERMINATED BY `\n`' at line 3

error 1064
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Should the last two strings be single quotes instead of backticks?
aussie_clint
Forum Commoner
Posts: 41
Joined: Mon Jul 31, 2006 9:14 am
Location: Brisbane, Australia
Contact:

Post by aussie_clint »

i tryed that
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have you considered using fgetcsv()?
aussie_clint
Forum Commoner
Posts: 41
Joined: Mon Jul 31, 2006 9:14 am
Location: Brisbane, Australia
Contact:

Post by aussie_clint »

i have had this working before, iv just stuffed up and not sure what im doing wrong
phpice
Forum Newbie
Posts: 4
Joined: Sun Feb 04, 2007 1:57 pm

Post by phpice »

From the original post, it looks like you are using tick marks (`) instead of single quotes (') for the "terminated by" settings.
aussie_clint
Forum Commoner
Posts: 41
Joined: Mon Jul 31, 2006 9:14 am
Location: Brisbane, Australia
Contact:

Post by aussie_clint »

thanks, i fixed that up but im still gettinmg 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 ''newprice list'
FIELDS TERMINATED BY ','
LINES TERMINATED BY

Code: Select all

LOAD DATA LOCAL INFILE '/home/computer/public_html/cwpriceCSV.csv'
INTO TABLE 'newprice list'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"newprice list" should be in backticks. Really, it shouldn't have a space in the name either... then it wouldn't require any backticks or quotes.
Post Reply