By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,903 Members | 1,922 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,903 IT Pros & Developers. It's quick & easy.

$Sql = "LOAD DATE.... Problem

P: n/a
Hello to all

I have a problem how to write correctly a PHP string.

I did the following import with the help of PHPMyAdmin:

Nombre d'enregistrements insérés : 364 (traitement: 0.0553
sec.)
requête SQL:
LOAD DATA LOCAL INFILE '/tmp/phpVfO8r8' INTO TABLE `fncid`
FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\'
LINES TERMINATED BY '\r\n'

I used this request in my PHP script like this:

$sql = "LOAD DATA LOCAL INFILE 'fncid.csv' INTO TABLE
'fncid' FIELDS TERMINATED BY ';' ENCLOSED BY '\"' ESCAPED
BY '\\\' LINES TERMINATED BY '\r\n'";

and get the following 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 ''fncid' FIELDS
TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\' LINES
TERMINATE' at line 1

I tried to remove the '' for the table name:

$Sql = "LOAD DATA LOCAL INFILE 'fncid.csv' INTO TABLE fncid
FIELDS TERMINATED BY ';' ENCLOSED BY '\"' ESCAPED BY '\\\'
LINES TERMINATED BY '\r\n'";
mysql_query($sql);
if(mysql_error()) {
echo mysql_error() ."<br>\n";
}

and this time I get the following error message:
The used command is not allowed with this MySQL version.
I use this request bei the same Provider, same database and
same table as the PHPMyAdmin did it!

I think I don't write correctly the PHP string for this
request!

Could somebody help me.

Regards

Otto

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Sat, 19 Feb 2005 09:18:30 +0100, Otto <oh****@freesurf.ch> wrote:
I have a problem how to write correctly a PHP string.

I did the following import with the help of PHPMyAdmin:

Nombre d'enregistrements insérés : 364 (traitement: 0.0553
sec.)
requête SQL:
LOAD DATA LOCAL INFILE '/tmp/phpVfO8r8' INTO TABLE `fncid`
Note the sort of quotes here - backticks, ` not single quotes '. This is an
identifier (a table in this case) - not a string value.
FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\'
LINES TERMINATED BY '\r\n'

I used this request in my PHP script like this:

$sql = "LOAD DATA LOCAL INFILE 'fncid.csv' INTO TABLE
'fncid' FIELDS TERMINATED BY ';' ENCLOSED BY '\"' ESCAPED
Now you've used single quotes - this won't work.
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 ''fncid' FIELDS
The parser's correctly pointed out the exact point of the error - the first
single quote starting a string literal where it's expecting a table identifier.
TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\' LINES
TERMINATE' at line 1

I tried to remove the '' for the table name:
Which should have been ``, but removing them altogether is generally even
better.
$Sql = "LOAD DATA LOCAL INFILE 'fncid.csv' INTO TABLE fncid
OK.
FIELDS TERMINATED BY ';' ENCLOSED BY '\"' ESCAPED BY '\\\'
LINES TERMINATED BY '\r\n'";
mysql_query($sql);
if(mysql_error()) {
echo mysql_error() ."<br>\n";
}

and this time I get the following error message:
The used command is not allowed with this MySQL version.
I use this request bei the same Provider, same database and
same table as the PHPMyAdmin did it!


Is this a version of PHPMyAdmin you installed yourself, or one provided by the
host? LOAD DATA LOCAL INFILE is subject to some security restrictions in MySQL;
if it's a host-provided PHPMyAdmin it's entirely possible they've got it
running using a slightly different setup that allows it, whereas other users
are restricted?

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

P: n/a
Hello Andy
Is this a version of PHPMyAdmin you installed yourself, or one provided by the
host? LOAD DATA LOCAL INFILE is subject to some security restrictions in MySQL;
if it's a host-provided PHPMyAdmin it's entirely possible they've got it
running using a slightly different setup that allows it, whereas other users
are restricted?

Many thanks four your quick answer. Yes I used the version installed from the
host. I will try to upload on my self to see if it's work...

Have a nice weekend

Otto

Jul 17 '05 #3

P: n/a
In article <li********************************@4ax.com>, Andy Hassall wrote:
Is this a version of PHPMyAdmin you installed yourself, or one provided by the
host? LOAD DATA LOCAL INFILE is subject to some security restrictions in MySQL;
if it's a host-provided PHPMyAdmin it's entirely possible they've got it
running using a slightly different setup that allows it, whereas other users
are restricted?

Your are right. I just installed my version of PHPMyAdmin and get this error!

Requête SQL:
LOAD DATA LOCAL INFILE '/tmp/phpTMofAQ' INTO TABLE `fncid` FIELDS TERMINATED BY
';' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'
MySQL a répondu:

#1148 - The used command is not allowed with this MySQL version
I will look for a another solution.

Thanks for your help.

Otto

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.