Page 1 of 2

load data local infile

Posted: Thu Mar 08, 2007 10:43 am
by bouncer
i have some problems in this code, especially in the query, because every time that i run it in php, it always shows "Invalid DATA LOAD query".
i have run this query in mysql prompt and it run without any problem, but give me some warnings (don“t know why) the same number of warnings as the number of rows that i have in the 'out.txt'

Code: Select all

$result = mysql_db_query('$dbName',"LOAD DATA LOCAL INFILE 'out.txt' REPLACE INTO TABLE exist FIELDS TERMINATED BY ','") or die ("Invalid DATA LOAD query");
can someone help me here ?

thanks in advance

Posted: Thu Mar 08, 2007 10:48 am
by volka
replace die ("Invalid DATA LOAD query")
by die (mysql_error())

Posted: Thu Mar 08, 2007 10:56 am
by bouncer
thanks volka

the problem was in '$dbName', i have changed it to $dbName without ' ', and it worked, because i have declared $dbName = 'database-name'; :lol:

Posted: Thu Mar 08, 2007 10:57 am
by volka
btw: mysql_db_query is marked as "deprecated"
http://de3.php.net/function.mysql_db_query wrote:This function is deprecated, do not use this function. Use mysql_select_db() and mysql_query() instead.

Posted: Thu Mar 08, 2007 11:08 am
by bouncer
volka wrote:btw: mysql_db_query is marked as "deprecated"
http://de3.php.net/function.mysql_db_query wrote:This function is deprecated, do not use this function. Use mysql_select_db() and mysql_query() instead.
thanks i have already changed it. :wink:

by the way, do you know how can i see warnings in mysql prompt i'm using 4.0.11 version of mysql in the help they say to use \W to show warnings but i use it and i continue without see warnings :? but it works just fine :wink:

Code: Select all

mysql>\W

Show warnings enable.
mysql> LOAD LOCAL DATA INFILE '/temp/out.txt' REPLACE INTO TABLE exist FIELDS TERMINATED BY ',';

bla bla bla ... and no warnings
mysql>_

thanks in advance

Posted: Thu Mar 08, 2007 12:44 pm
by mikeq
issue the statement

mysql>show warnings;

that should show you the last warning issued

Posted: Thu Mar 08, 2007 12:55 pm
by bouncer
mikeq wrote:issue the statement

mysql>show warnings;

that should show you the last warning issued
i have already use that and nothing appears :? , keeps saying that i have a error of syntax...

Posted: Thu Mar 08, 2007 2:42 pm
by volka
Does that mean bla bla bla actually stands for an error message?
If there are syntax errors you won't get warnings because the syntax error stops processing the statement before warnings may occur.
So, bla bla bla translates to ...?



you might want to check the correct syntax at http://dev.mysql.com/doc/refman/5.1/en/load-data.html

Posted: Fri Mar 09, 2007 12:37 pm
by bouncer
volka wrote:Does that mean bla bla bla actually stands for an error message?
If there are syntax errors you won't get warnings because the syntax error stops processing the statement before warnings may occur.
So, bla bla bla translates to ...?
translates to ....

Query: OK, 34574 rows affected (0.69 sec)
Records: ***** ......

thanks in advance

Posted: Fri Mar 09, 2007 12:50 pm
by volka
bouncer wrote:keeps saying that i have a error of syntax...
e ...where? Not in
bouncer wrote:Query: OK, 34574 rows affected (0.69 sec)
Records: ***** ......

Posted: Fri Mar 09, 2007 12:55 pm
by bouncer
yes, just in the end of reports

Posted: Fri Mar 09, 2007 1:01 pm
by volka
what?

Posted: Fri Mar 09, 2007 1:04 pm
by bouncer
in the end of this:

Query: OK, 34574 rows affected (0.69 sec)
Records: ***** ......

Posted: Fri Mar 09, 2007 1:08 pm
by volka
Ok, let me ask a question: Do you think the actual error message might help us to solve this? Yes or no?

Posted: Fri Mar 09, 2007 1:11 pm
by bouncer
no, the message only tell us to consult the mySQL manual :roll: