Major problems trying to use load data local infile
| From: | Victor Spång Arthursson | Date: | Tue, 24 Feb 2004 15:05:15 +0000 |
| Subject: | Major problems trying to use load data local infile | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-178703@lists.php.net to get a copy of this message | ||
Hi!
Been trying all day to be able to fire off a load data local infile using php, but haven't yet succeded…
The setup is as follows: the client should upload a .csv-file to the webserver. Here, php shall issue a load data local infile…-statement to load the data into a mysql-database.
The database, on the other hand, is located on another server, which is the reason to do a local insert…
So far I haven't managed to get it to work, other than from the terminal mysql client.
My SQL is as follows (works in the client, locally, when I connect to the remote server):
LOAD DATA LOCAL INFILE 'd:\\home\\host\\www\\test\\ejerskifte\\output.txt' INTO TABLE table FIELDS TERMINATED BY '\\t' ESCAPED BY '\\' LINES TERMINATED BY '\r'
PHP-code:
<?php
include("includes/settings.php");
include("includes/db_connect_and_choose.php");
$strSQL = "LOAD DATA LOCAL INFILE '" . addslashes(realpath("output.txt")) . "' INTO TABLE table FIELDS TERMINATED BY '" .addslashes('\t') . "' ESCAPED BY '\\' LINES TERMINATED BY '" . '\r' . "'";
echo $strSQL;
mysql_query($strSQL) or die (mysql_error());
?>
Would be very thankful if anyone had any input on this,
sincerely
Victor Spång Arthursson