Re: load data infile -- problem
| From: | Bastien Koert | Date: | Thu, 18 Aug 2005 14:34:32 +0000 |
| Subject: | Re: load data infile -- problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40107@lists.php.net to get a copy of this message | ||
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: dpgirago@mdanderson.org To: Miles Thompson <miles@allnovascotia.com> CC: php-db-list <php-db@lists.php.net> 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:*.csvHelo 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 aengine.file on my local harddisk, with my php application, managing my mysqlSo, in command line, all works fine, all records are correctly imported. ---------------- <command line code> -------------------------mysql load data infile 'c:\\datastream\\import\import->into table iport -> fields terminated by ';' -> ignore 9 lines; ----------------- </command line code> ------------------------ 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. ------------------ <php code> ------------------- $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 ("<br>Executia comenzii <i>$query</i> a esuat.<br>"); ------------------ </php code> ---------------------- 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, select.now@gmail.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php