Following is my sql query which worked fine when i ran it from phpmyadmin but when i ran the same query through PHP then the query didnot worked and gave me following error. Kindly let me know how can I run this query from my php file so it will create the output file in the specified folder. Thanks,
QUERY
SELECT * FROM lahore_student INTO OUTFILE 'b://uploaded//data.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '".'"'."'
LINES TERMINATED BY '\n'
Output: It creates file to my b drive in FOLDER named as Uploaded
ERROR:
File ‘b:uploadeddata.csv’ already exists
NOTE: The uploaded folder was empty
It looks you are trying to run this on a windows system, which requires special treatment of directory separators.
Try:
Or:
Also note that this will not overwrite an existing file (which is the error you are getting). So you need to make sure that any file with that name is deleted first.
See the
The “\” path name separator charactersection on this page in the MYSQL docs:http://dev.mysql.com/doc/refman/5.0/en/limits-windows.html