Help please!
I can successfully load a data file into a MySQL database running on my Win98 laptop using the following SQL statements entered from a mysql session.
USE my_db;
LOAD DATA LOCAL INFILE "sirextract2.txt" INTO TABLE issues
FIELDS
TERMINATED BY ','
ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
;
When I try to perform the same operation from a PHP script against the same data and database, I get screwed up data loaded. The PHP script I am using is:
$host = "localhost";
$user = "root";
$password = "secret";
$database = "my_db";
$query = "DELETE from issues";
mysql_connect($host, $user, $password);
mysql_select_db($database);
$query = "DELETE from issues";
$result = mysql_query($query);
// debug statement
echo("<BR>The result of the delete: $result");
$query = "LOAD DATA LOCAL INFILE \"sirextract2.txt\" INTO TABLE issues
FIELDS
TERMINATED BY ','
ENCLOSED BY '\"'
LINES TERMINATED BY '\n'";
$result = mysql_query($query);
// debug statements:
echo("<BR>The query string is: $query");
echo("<BR>The result of the load: $result");
?>
I have experimented with escaping and not escaping the back-slashes in the enclosed by and lines terminated by statements with no success.