salami1_1 Posted January 22, 2009 Share Posted January 22, 2009 Hi, I've been searching for examples and read the Mysql docs but I just can't see the error: My code: $sql = "LOAD DATA INFILE '$tmpfile_lng1_name' REPLACE INTO TABLE $table1 (id, content, lastupdated) FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\n'"; The file has 1 line atm to test which is: "216";"SRS <span class=blue>forbidden</span>";"2009-01-22 01:01:53"; The file was originally \t delimited and tried that too but same error always. The 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 'FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY ' '' at line 1 The query echo'd with the error gives: LOAD DATA INFILE 'credit/en.txt' REPLACE INTO TABLE ics_lng_en (id, content, lastupdated) FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY ' ' as you see the prob is not with the variables the \ and the \n in the query are gone because its echo'd and browser sees them as code. Can anybody help me? Thanks, I've been staring at this for the last 2 days. Best regards, P.s. I also tried LOAD DATA LOCAL INFILE; same error, also tried removing the field ( '(id, content, lastupdated)' ) Quote Link to comment https://forums.phpfreaks.com/topic/141905-solved-load-data-infile-syntax-error/ Share on other sites More sharing options...
Mchl Posted January 22, 2009 Share Posted January 22, 2009 If MySQL says error is 'near FIELDS TERMINATED BY... ' it usually means, there's something wrong just BEFORE 'FIELDS TERMINATED BY' MySQL manual doesn't list 'REPLACE' as a viable part of 'LOAD DATA INFILE' statement... where did you get it? http://dev.mysql.com/doc/refman/5.1/en/load-data.html [edit] Got my glasses on Quote Link to comment https://forums.phpfreaks.com/topic/141905-solved-load-data-infile-syntax-error/#findComment-743045 Share on other sites More sharing options...
salami1_1 Posted January 22, 2009 Author Share Posted January 22, 2009 yeah I know how that error reporting works.. but I just don't see the error.. aaah I found a way that it works: $sql = "LOAD DATA INFILE '".$tmpfile_lng1_name."' REPLACE INTO TABLE ".$table1." FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\n'"; I tried before without specifying the table columns but then I had ENCLOSED BY '\"' before the word FIELDS which is bad. Now I'm getting access denied error but on my quest of searching for this answer I saw that error passing by multiple times to I'll bet I can find some answer for that using my friend google. thanks Quote Link to comment https://forums.phpfreaks.com/topic/141905-solved-load-data-infile-syntax-error/#findComment-743085 Share on other sites More sharing options...
salami1_1 Posted January 22, 2009 Author Share Posted January 22, 2009 and then I find out that my hosting (Bluehost) doesn't even support this mysql functionality despite the fact they actually pointing me out to an article in THEIR helpdesk database which tells you using LOAD DATA INFILE is very good and fast blablabla ergo, waste of time. humppff time for some dedicated hosting b.r. Quote Link to comment https://forums.phpfreaks.com/topic/141905-solved-load-data-infile-syntax-error/#findComment-743138 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.