0

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'
4
  • can u give us what $csv equals or an example of it? Commented Feb 16, 2012 at 20:21
  • did you escape the slashes? i.e. "\\" Commented Feb 16, 2012 at 20:21
  • yo can see what $csv equals in the statement I echoed out above (right below "ERROR") Commented Feb 16, 2012 at 20:22
  • C:\FileClean\output\6eai1mikqkidpe1re77e8a6jn2trial_new.csv Commented Feb 16, 2012 at 20:23

3 Answers 3

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

\ is a special character--the string escape character--so it's probably doing strange things. Try addslashes to make them \\ instead.

Comments

0

You have to escape the slashes in $csv, like so:

"C:\\FileClean\\output\\6eai1mikqkidpe1re77e8a6jn2trial_new.csv"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.