Reputation: 37
I've tried using PHP scripts found online with no success, so i reverted to using the mySQL Syntax OUTFILE, here's the current code i'm trying to use although it's throwing a few errors
SELECT Name, ID INTO OUTFILE 'data.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM data
It's throwing an error as shown below
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Upvotes: 1
Views: 2201
Reputation: 2120
Looks like this error is thrown by PHP. Try escaping the double quotes
SELECT Name, ID INTO OUTFILE 'data.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM data
If this above query is working, then try escaping the backward slash again.
SELECT Name, ID INTO OUTFILE 'data.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"'
ESCAPED BY '\\\\'
LINES TERMINATED BY '\n'
FROM data
Upvotes: 2