Re: [PHP-DB] load data infile -- problem
is the file sitting on the same server as the db? Are the webserver and db on the same machine? If they are not, and the file uploaded to the webserver, the db sesrver machine won't have access to the file unless you ftp it over... You may want/need to investigate a more php based approach where you open the file and read it in, parsing thru it to access the data elements and running sql statements thru a loop Bastien From: [EMAIL PROTECTED] To: Miles Thompson <[EMAIL PROTECTED]> CC: php-db-list Subject: Re: [PHP-DB] load data infile -- problem Date: Thu, 18 Aug 2005 09:25:22 -0500 You can definitely do a "load file" from within the mysql client, so I'd guess you can do it through mysql_query, too. I'm wondering about the semi-colon within the query. Maybe it needs to be escaped, too. David > I could be 100% wrong on this, but I do not think that a command line > statement can be executed through mysql_query() - try exec(). > If I remember correctly mysql load data infile ... is not executed from > within mysql, but at the command line. > (Hint: look at the source for phpMyAdmin and copy how it is done.) > Regards - Miles At 08:30 AM 8/18/2005, select.now wrote: >>Helo everyone ! >>I find this problem and I think I am close to the solution but ... >> >>The question: I need to import a few thousand of record storee in a *.csv >>file on my local harddisk, with my php application, managing my mysql engine. >> >>So, in command line, all works fine, all records are correctly imported. >> - >> >mysql load data infile 'c:\\datastream\\import\import >>->into table iport >>-> fields terminated by ';' >>-> ignore 9 lines; >>- >> >>But in my php app, because I am confuse a bit (use of ['], ["] and the >>definition of variables in mysql_query), I don't make this import. >> >>-- --- >>$a = 'c:\\\datastream\\\import\\\import'; >>$extra_arg = 'fields terminated by \';\' ignore 9 lines;'; >>$query = 'load data infile \''.$a.'\' into table import '.$extra_arg.''; >>$result = mysql_query ($query) or die_mysql ("Executia comenzii >>$query a esuat."); >>-- -- >> >>I get this output-error: >>=== >> load data infile 'c:\\datastream\\import\\import' into table import >> fields terminated by ';' ignore 9 lines; >>=== >>and the import doesn't occured. >> >> >>Where is located my mistake ? >> >>Thanks in advance. >> >>-- >>cu respect, [EMAIL PROTECTED] >> >>-- >>PHP Database Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] load data infile -- problem
You can definitely do a "load file" from within the mysql client, so I'd guess you can do it through mysql_query, too. I'm wondering about the semi-colon within the query. Maybe it needs to be escaped, too. David > I could be 100% wrong on this, but I do not think that a command line > statement can be executed through mysql_query() - try exec(). > If I remember correctly mysql load data infile ... is not executed from > within mysql, but at the command line. > (Hint: look at the source for phpMyAdmin and copy how it is done.) > Regards - Miles At 08:30 AM 8/18/2005, select.now wrote: >>Helo everyone ! >>I find this problem and I think I am close to the solution but ... >> >>The question: I need to import a few thousand of record storee in a *.csv >>file on my local harddisk, with my php application, managing my mysql engine. >> >>So, in command line, all works fine, all records are correctly imported. >> - >> >mysql load data infile 'c:\\datastream\\import\import >>->into table iport >>-> fields terminated by ';' >>-> ignore 9 lines; >>- >> >>But in my php app, because I am confuse a bit (use of ['], ["] and the >>definition of variables in mysql_query), I don't make this import. >> >>-- --- >>$a = 'c:\\\datastream\\\import\\\import'; >>$extra_arg = 'fields terminated by \';\' ignore 9 lines;'; >>$query = 'load data infile \''.$a.'\' into table import '.$extra_arg.''; >>$result = mysql_query ($query) or die_mysql ("Executia comenzii >>$query a esuat."); >>-- -- >> >>I get this output-error: >>=== >> load data infile 'c:\\datastream\\import\\import' into table import >> fields terminated by ';' ignore 9 lines; >>=== >>and the import doesn't occured. >> >> >>Where is located my mistake ? >> >>Thanks in advance. >> >>-- >>cu respect, [EMAIL PROTECTED] >> >>-- >>PHP Database Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] load data infile -- problem
I could be 100% wrong on this, but I do not think that a command line statement can be executed through mysql_query() - try exec(). If I remember correctly mysql load data infile ... is not executed from within mysql, but at the command line. (Hint: look at the source for phpMyAdmin and copy how it is done.) Regards - Miles At 08:30 AM 8/18/2005, select.now wrote: Helo everyone ! I find this problem and I think I am close to the solution but ... The question: I need to import a few thousand of record storee in a *.csv file on my local harddisk, with my php application, managing my mysql engine. So, in command line, all works fine, all records are correctly imported. - >mysql load data infile 'c:\\datastream\\import\import ->into table iport -> fields terminated by ';' -> ignore 9 lines; - But in my php app, because I am confuse a bit (use of ['], ["] and the definition of variables in mysql_query), I don't make this import. -- --- $a = 'c:\\\datastream\\\import\\\import'; $extra_arg = 'fields terminated by \';\' ignore 9 lines;'; $query = 'load data infile \''.$a.'\' into table import '.$extra_arg.''; $result = mysql_query ($query) or die_mysql ("Executia comenzii $query a esuat."); -- -- I get this output-error: === load data infile 'c:\\datastream\\import\\import' into table import fields terminated by ';' ignore 9 lines; === and the import doesn't occured. Where is located my mistake ? Thanks in advance. -- cu respect, [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] load data infile -- problem
Helo everyone ! I find this problem and I think I am close to the solution but ... The question: I need to import a few thousand of record storee in a *.csv file on my local harddisk, with my php application, managing my mysql engine. So, in command line, all works fine, all records are correctly imported. - >mysql load data infile 'c:\\datastream\\import\import ->into table iport -> fields terminated by ';' -> ignore 9 lines; - But in my php app, because I am confuse a bit (use of ['], ["] and the definition of variables in mysql_query), I don't make this import. -- --- $a = 'c:\\\datastream\\\import\\\import'; $extra_arg = 'fields terminated by \';\' ignore 9 lines;'; $query = 'load data infile \''.$a.'\' into table import '.$extra_arg.''; $result = mysql_query ($query) or die_mysql ("Executia comenzii $query a esuat."); -- -- I get this output-error: === load data infile 'c:\\datastream\\import\\import' into table import fields terminated by ';' ignore 9 lines; === and the import doesn't occured. Where is located my mistake ? Thanks in advance. -- cu respect, [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] LOAD DATA LOCAL INFILE
Hello I'm new to this list. I diden't found anything in the archive and by googleing to solve my problem. We have updated our server to PHP 4.3.8 and MySQL 4.0.2. Some of our clients run a shop software that need 'LOAD DATA LOCAL INFILE' to store its data to MySQL. MySQL itself supports the command. I can run it from mysql-client. That works. I have read about the fix on php.net (http://www.php.net/ChangeLog-4.php / http://bugs.php.net/28632). Until now, i couldn't find a solution to get it work. Is there way to get it work? Regards Dani -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Load Data infile help needed
Hi there everyone, I'm having a problem loading in a text file, each column is enclosed with a " and separated by a , but when I try the below, it loads in the data BUT it puts a " to the left of each character. Any help would be really appreciated. Thank you Chris mysql_query("LOAD DATA INFILE 'c:/apache/htdocs/example/20040624.txt' INTO TABLE import FIELDS TERMINATED BY '\\\"' ESCAPED BY '\\,' LINES TERMINATED BY '\\r\\n'");
RE: [PHP-DB] Load data infile problem
Actually, I have just figured it out. It had to do with the 'slashes' around the query. The original $sql code was created using phpmyadmin, but I messed around with it until it worked, now using the following query: mysql_query("LOAD DATA INFILE 'C:abc.txt' INTO TABLE abc FIELDS TERMINATED BY '\\t' ESCAPED BY '\\\' LINES TERMINATED BY '\\r\\n'"); So it was the query formatting which was the problem. Thanks Justin -Original Message- From: Jonathan Haddad [mailto:[EMAIL PROTECTED] Sent: Tuesday, 8 June 2004 2:06 PM To: Baiocchi, Justin (LI, Armidale) Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Load data infile problem does your server have the post variables set as globals? you might have to use $_POST['submit'] instead. On Jun 7, 2004, at 9:17 PM, <[EMAIL PROTECTED]> wrote: > Hello, > > I have a page with a button that when clicked loads a pre-determined > text file into my database. The code is posted below. > However, when clicked the button does nothing, just opens up the same > page again. The data does not get loaded into the database. any ideas? > > Thanks > Justin > > The page is viewall.php which has the button on it. So I want it (when > clicked) to update the database and return to the page. > > > > > > if ($submit) { > $dbH = mysql_connect('localhost', 'root', 'password') or die('Could > not connect to MySQL server.' . mysql_error()); > > mysql_select_db("options"); > > $sql = 'LOAD DATA INFILE \'C:abc.txt\' REPLACE INTO TABLE > `abc`' > . 'FIELDS TERMINATED BY \'\\t\'' > . 'ENCLOSED BY \'"\'' > . 'ESCAPED BY \'\'' > . 'LINES TERMINATED BY \'\\r\\n\''; > } > ?> > > $d = "". " name=submit value='Submit'>"; > echo "$d"; ?> > > -- Jonathan Haddad [EMAIL PROTECTED] http://www.superwebstuff.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Load data infile problem
Hello, I have a page with a button that when clicked loads a pre-determined text file into my database. The code is posted below. However, when clicked the button does nothing, just opens up the same page again. The data does not get loaded into the database. any ideas? Thanks Justin The page is viewall.php which has the button on it. So I want it (when clicked) to update the database and return to the page. ' . mysql_error()); mysql_select_db("options"); $sql = 'LOAD DATA INFILE \'C:abc.txt\' REPLACE INTO TABLE `abc`' . 'FIELDS TERMINATED BY \'\\t\'' . 'ENCLOSED BY \'"\'' . 'ESCAPED BY \'\'' . 'LINES TERMINATED BY \'\\r\\n\''; } ?> ". ""; echo "$d"; ?>
[PHP-DB] load data
when using the 'load data infile' commands how do i force the data thats being loaded to completely be loaded ie LOAD DATA INFILE "data.txt" INTO TABLE datacontent.misc_code; I have a file eg: data.txt thats 36 lines long, but is full of misc text including some php + mysql code, so its not poss for me to import the text saying that lines are terminated by "x" because the "x" could be in the code thats 'in the file' my db table consisted of two tables id, misc_code. id is autonumber, and i want to imort the 'whole' of a data.txt text file into the 'misc_code' field. whats happening to me is that when i run the command LOAD DATA INFILE "data.txt" INTO TABLE datacontent.misc_code; Its importing the file but its importing it into hundreds of rows, because the mysql is seeing the " / ; ' as seperate fields etc or rather as a new row for the misc_code table. I cannot use a string replace with php into the text file because the text file content has to be kept exactly. so how do i force the load data infile, to import the whole of the contents of the file into a single insertion from the first byte of the file to its eof, Hope someone can help Steven -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] LOAD DATA INFILE
hi, could you help me? i have got this php code $importfilename = $importdir_web . $importfile; echo $importfilename . ''; $vysledekupdate = MySQL_DB_Query("$dbname","LOAD DATA LOCAL INFILE '$importfilename' INTO TABLE shop_rates FIELDS TERMINATED BY ';' LINES TERMINATED BY '\r\n'"); if ($vysledekupdate == false) echo '' . MySQL_Error() . ''; else echo 'Import ok.'; $cenaquery = MySQL_DB_Query("$dbname","SELECT * FROM shop_rates"); if ($cenaquery == false) echo MySQL_Error() . ''; echo 'Updated:'; echo ''; while ($zaznamcena = MySQL_Fetch_Array($cenaquery)) : { echo '' . $zaznamcena[id_item] . '' . $zaznamcena[c1] . '' . $zaznamcena[c2] . '' . $zaznamcena[c3] . '' . $zaznamcena[c4] . '' . $zaznamcena[dph] . '' . $zaznamcena[jednotka] . ''; } endwhile; echo ''; content of the file /home/abianet/e.abianet.cz/importc/1033573485.obabia.www.sql just two rows 19;20500;19400;0;0;22;ks 17;2;19900;0;0;22;ks table shop_rates structure id_item, c1, c2, c3, c4, dph, jednotka this is the web/html output /home/abianet/e.abianet.cz/importc/1033573485.obabia.www.sql Import ok. Updated: 17 10440.00 0.00 0.00 0.00 22 ks 19 0.00 0.00 0.00 0.00 22 ks so that means tha import wasnot ok could you help me? thanks karel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] load data
On Monday 15 July 2002 22:03, Natividad Castro wrote: > Hi to all, > I changed Linux from version 7.2 to 7.3 and now when I try to load data > using LOAD DATA LOCAL INFILE I got the following error: > The used command is not allowed with this MySQL version. I > enable --local-infile=1 But I'm still getting the same error. > > Any help, is greatly appreciate it You would most likely get better help from the MySQL list. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* A mathematician is a device for turning coffee into theorems. -- P. Erdos */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] load data
Hi to all, I changed Linux from version 7.2 to 7.3 and now when I try to load data using LOAD DATA LOCAL INFILE I got the following error: The used command is not allowed with this MySQL version. I enable --local-infile=1 But I'm still getting the same error. Any help, is greatly appreciate it Thanks in advanced Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Load data
Hi to all, I changed Linux from version 7.2 to 7.3 and now when I try to load data using LOAD DATA LOCAL INFILE I got the following error: The used command is not allowed with this MySQL version. I enable --local-infile=1 But I'm still getting the same error. Any help, is greatly appreciate it Thanks in advanced Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Load data
Hi to all, I changed Linux from version 7.2 to 7.3 and now when I try to load data using LOAD DATA LOCAL INFILE I got the following error: The used command is not allowed with this MySQL version. I enable --local-infile=1 But I'm still getting the same error. Any help, is greatly appreciate it Thanks in advanced Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] load data infile problem
You running Windows or *nix? File permissions will play a part in this, but use PHP's exec() function to execute MySQL's load data infile. The manual has a number of well annotated examples. The big problem may be that you'll be executing the command as whatever user the web server is running as. But before you start reinventing the wheel, search for "MySQL import csv PHP", or something similar, and check out the script sites referred to in the links part of the manual. This isn't a new problem and has been addressed before. HTH - Miles Thompson At 09:13 PM 1/19/2002 +, rop30999 wrote: >I have a called file cats.txt which count data that were solitary of a DB >Access. >I need to export these data for a table 'cats' inside of a DB done in MySql. > >In MySql I can execute this procedure in the following way: > >Load data local infile "gatos.txt" >into table gatos >fields >terminated by ',' >enclosed by '"' >(Id, Nome, Raça); > >I need to know how I can accomplish this same operation but using PHP > >Thank you > >Paulo > > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] load data infile problem
I have a called file cats.txt which count data that were solitary of a DB Access. I need to export these data for a table 'cats' inside of a DB done in MySql. In MySql I can execute this procedure in the following way: Load data local infile "gatos.txt" into table gatos fields terminated by ',' enclosed by '"' (Id, Nome, Raça); I need to know how I can accomplish this same operation but using PHP Thank you Paulo -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] LOAD DATA LOCAL ERROR
I may be not understanding properly without checking your MySQL syntax, but should it not be "C:\WINDOWS\Desktop\db.txt"? Tom At 08:53 10/07/2001 -0500, you wrote: >Every time I use the command > >LOAD DATA LOCAL INFILE "C:WINDOWS:Desktop:db.txt" INTO TABLE booktest; > >I get this error message... > >ERROR: >File 'C:WINDOWS:Desktop:db.txt' not found (Errcode: 2) > > >How can I load my file to the database??? > >--Will -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] LOAD DATA LOCAL ERROR
Every time I use the command LOAD DATA LOCAL INFILE "C:WINDOWS:Desktop:db.txt" INTO TABLE booktest; I get this error message... ERROR: File 'C:WINDOWS:Desktop:db.txt' not found (Errcode: 2) How can I load my file to the database??? --Will
[PHP-DB] Load data infile + NULL
I get *.csv file like this (1 string): 7,'Markovic Stevo','NULL','NULL' When I use LOAD DATA INFILE syntax I get word NULL in cell (MySQL table) q: I want cell to be empty (in table), where the NULL is (in *.csv), how? tomaz, Slovenia
Re: [PHP-DB] load data conditionally
I think you could do this. Load all the data. Then "delete from table where name != extension" At 08:01 PM 1/30/01 -0500, Mark @ 10base-t wrote: >Hey there, >Can you use the load data infile command to load stuff in only if certain >fields match? Or would I have to do this via some php loop? > >Basically I have a txt file with 5 fields in it. First name, extension, >space, seat, cluster. > >I only wanna update a record with the space seat and cluster information as >long as the extension and first name are a match. > >Thanks! >Marky > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] load data conditionally
Hey there, Can you use the load data infile command to load stuff in only if certain fields match? Or would I have to do this via some php loop? Basically I have a txt file with 5 fields in it. First name, extension, space, seat, cluster. I only wanna update a record with the space seat and cluster information as long as the extension and first name are a match. Thanks! Marky -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]