Re: MySQL error
| From: | Richard Davey | Date: | Fri, 01 Jul 2005 10:29:25 +0000 |
| Subject: | Re: MySQL error | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-217965@lists.php.net to get a copy of this message | ||
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
WR> '\' 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