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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php