Reputation: 1246
I am echoing the statement out right above the mysql_query statement, and for some reason the slashes in the csv file are being stripped? I get the error you can see below. Any insights?
echo "LOAD DATA LOCAL INFILE '" . $csv . "' INTO TABLE mytable FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES";
mysql_query("LOAD DATA LOCAL INFILE '" . $csv . "' INTO TABLE mytable FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES") or die(mysql_error());
ERROR:
LOAD DATA LOCAL INFILE 'C:\FileClean\output\6eai1mikqkidpe1re77e8a6jn2trial_new.csv' INTO TABLE mytable FIELDS TERMINATED BY ',' LINES TERMINATED BY ' ' IGNORE 1 LINES Can't find file 'C:FileCleanoutput6eai1mikqkidpe1re77e8a6jn2trial_new.csv'
Upvotes: 0
Views: 453
Reputation: 1437
You have to escape the slashes in $csv, like so:
"C:\\FileClean\\output\\6eai1mikqkidpe1re77e8a6jn2trial_new.csv"
Upvotes: 0
Reputation: 11595
\
is a special character--the string escape character--so it's probably doing strange things. Try addslashes
to make them \\
instead.
Upvotes: 1
Reputation: 1084
You need to escape the slashes by adding another slash in front of each in the $csv file path.
example:
C:\\FileClean\\output\\6eai1mikqkidpe1re77e8a6jn2trial_new.csv
Upvotes: 1