You are here: Re: [PHP] MySQL error « PHP « IT news, forums, messages
Re: [PHP] MySQL error

Posted by Richard Davey on 07/01/05 13:29

Hello Wessley,

Friday, July 1, 2005, 10:55:16 AM, you wrote:

WR> $sql = "LOAD DATA LOCAL INFILE '/path/to/file.txt' INTO TABLE
WR> `mytable` FIELDS TERMINATED BY '\t' ESCAPED BY '\' LINES TERMINATED
WR> BY '\n'";
WR> mysql_query($sql) or die('<br><br>'.mysql_error());

WR> I get this MySQL error:
WR> You have an error in your SQL syntax. Check the manual that
WR> corresponds to your MySQL server version for the right syntax to use
WR> near ''' at line 2

It looks to me like the \n (linefeed) character is actually being
turned into a line-feed character, because you've quoted the $sql
variable with " " - hence it's gone and turned \t into a tab, \n into
a line-feed, etc. I may be wrong, but I don't think MySQL likes this,
and given the error you are receiving it looks like that might be the
case. Quote it with ' ' to avoid translation of the \n and \t.

Best regards,

Richard Davey
--
http://www.launchcode.co.uk - PHP Development Services
"I do not fear computers. I fear the lack of them." - Isaac Asimov

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация