Ask a Question related to PHP Development, Design and Development.
-
Dave #1
help : LOAD DATA LOCAL INFILE
I'm trying to load a local file in to a database and have had no luck.
I have downloaded the table contents (1row) using phpAdmin and changed the id# and one
other field before trying to upload. To test out the script.
That file looks like this (dbdata.txt)
"2","public","company2","contact","street","suite" ,"city","province","postcode","countr
y","phone","fax","region","service","first name","surname","create date"
The script i'm trying to use looks like this.
$loadfile = "LOAD DATA LOCAL INFILE 'dbdata.txt' INTO TABLE tablename FIELDS TERMINATED
BY ',' ENCLOSED BY '\"'";
$result = mysql_query($loadfile) or die (" Invalid DATA LOAD query");
Both files are in the same directory and I am able to connect to the table and query it
within the rest of the script.
Any help you can give on this is appreciated.
Thanks,
Dave Guest
-
LOAD DATA INFILE problem
Consider the following table and csv file: ------------------------------------------- CREATE TABLE `table_test` ( `c1` VARCHAR( 255 ) NOT NULL... -
LOAD DATA INFILE
Hello ng, I'm trying to do this mysql query but I receive an error. Can someone help me? LOAD DATA INFILE... -
Complex LOAD DATA INFILE
Dear mysql-ians, I am using mysql 5.0 and I want to load a huge txt-file in my database. My text file (file.txt) looks like: col1 col2 col3... -
Load Data Infile question
I just tried to execuete a Load Data Infile command to import data from a .cvs file into a mysql table, but I get the following error. Any help at... -
LOAD DATA LOCAL INFILE and Perl DBI/DBD
HI all, For the past several months we have been using LOAD DATA LOCAL INFILE to bulk load tables within Perl modules. Recently, someone... -
Tony #2
Re: help : LOAD DATA LOCAL INFILE
Dave wrote:
> I'm trying to load a local file in to a database and have had no luck.
Try asking the MySQL server first - it should help point you in the right
direction.
$result = mysql_query($loadfile)
or die ("Error ".mysql_errno() ." : ".mysql_error() ."");
"2","public","company2","contact","street","suite" ,"city","province","postco> I have downloaded the table contents (1row) using phpAdmin and
> changed the id# and one other field before trying to upload. To test
> out the script.
>
> That file looks like this (dbdata.txt)
>
>
de","countr> y","phone","fax","region","service","first name","surname","create
> date"
>
>
> The script i'm trying to use looks like this.
>
> $loadfile = "LOAD DATA LOCAL INFILE 'dbdata.txt' INTO TABLE tablename
> FIELDS TERMINATED BY ',' ENCLOSED BY '\"'";
> $result = mysql_query($loadfile) or die (" Invalid DATA LOAD query");
This is what phpMyAdmin generated for a similar csv file:
$loadfile=
'LOAD DATA LOCAL INFILE
\'/path-to-your-server/dbdata.csv\' INTO TABLE
`tablename`
FIELDS TERMINATED BY \',\' ENCLOSED BY \'"\'
ESCAPED BY \'\\\\\' LINES TERMINATED BY \'\\r\\n\'';
// cue the result or tell us why not..
$result = mysql_query($loadfile)
or die ("Error ".mysql_errno() ." : ".mysql_error() ."");
Note the path-to-your-server may be something like
/home/htdocs/xxxxx/dbdata.txt
Hope that helps
--
Tony
Tony Guest
-
Andy Hassall #3
Re: help : LOAD DATA LOCAL INFILE
On Mon, 04 Oct 2004 14:42:57 -0500, [email]me@here.com[/email] (Dave) wrote:
You haven't said what problems you're having. Use mysql_error() to get an>I'm trying to load a local file in to a database and have had no luck.
>
>
>I have downloaded the table contents (1row) using phpAdmin and changed the id# and one
>other field before trying to upload. To test out the script.
>
>That file looks like this (dbdata.txt)
>
>"2","public","company2","contact","street","suite ","city","province","postcode","countr
>y","phone","fax","region","service","first name","surname","create date"
>
>
>The script i'm trying to use looks like this.
>
>$loadfile = "LOAD DATA LOCAL INFILE 'dbdata.txt' INTO TABLE tablename FIELDS TERMINATED
>BY ',' ENCLOSED BY '\"'";
>$result = mysql_query($loadfile) or die (" Invalid DATA LOAD query");
>
>Both files are in the same directory and I am able to connect to the table and query it
>within the rest of the script.
error message, and post this message.
Actually - put the error message into Google first - you are likely hitting
the security constraints placed on LOAD DATA LOCAL INFILE by MySQL itself.
--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Andy Hassall Guest
-
Dave #4
Re: help : LOAD DATA LOCAL INFILE
In article <rkk3m05f2m77m86jhfoiphgn21gbvj1bcg@4ax.com>, [email]andy@andyh.co.uk[/email]
says...id# and one>
>On Mon, 04 Oct 2004 14:42:57 -0500, [email]me@here.com[/email] (Dave) wrote:
>>>I'm trying to load a local file in to a database and have had no luck.
>>
>>
>>I have downloaded the table contents (1row) using phpAdmin and changed thede","countr>>other field before trying to upload. To test out the script.
>>
>>That file looks like this (dbdata.txt)
>>
>>"2","public","company2","contact","street","suit e","city","province","postcoTERMINATED>>y","phone","fax","region","service","first name","surname","create date"
>>
>>
>>The script i'm trying to use looks like this.
>>
>>$loadfile = "LOAD DATA LOCAL INFILE 'dbdata.txt' INTO TABLE tablename FIELDSand query it>>BY ',' ENCLOSED BY '\"'";
>>$result = mysql_query($loadfile) or die (" Invalid DATA LOAD query");
>>
>>Both files are in the same directory and I am able to connect to the table>>>within the rest of the script.
> You haven't said what problems you're having. Use mysql_error() to get an
>error message, and post this message.
>
> Actually - put the error message into Google first - you are likely hitting
>the security constraints placed on LOAD DATA LOCAL INFILE by MySQL itself.
>
>--
>Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
><http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
I added the script above and the error i'm getting is.
Error 1148 : The used command is not allowed with this MySQL version
Thanks again
Dave Guest



Reply With Quote

