Fahim
Fahim

Reputation: 11

SELECT * INTO OUTFILE directory

I am trying to generate a file from mysql. The I am using is:

SELECT * INTO OUTFILE $_SERVER['DOCUMENT_ROOT']/data.txt FIELDS TERMINATED BY ',' FROM admin";

The code is working fine as I am not getting any error. But the problem is I could not locate where the file is created. Would any body please help me.

I am using a shared hosting.

Thanks

Upvotes: 1

Views: 3945

Answers (2)

Saiyam Patel
Saiyam Patel

Reputation: 1161

you are using shared hosting then good way to connect ftp and get the path of physical working directory, you can get form "pwd" linux command

use that path because at the shared host make some time issue

Upvotes: 0

Shiplu Mokaddim
Shiplu Mokaddim

Reputation: 57650

The query should be run like this, I mean it should be quoted.

mysql_query("SELECT * INTO OUTFILE '{$_SERVER['DOCUMENT_ROOT']}/data.txt' FIELDS TERMINATED BY ',' FROM admin";");

To successfully run this query you'll need these

  1. User must have FILE privilege
  2. MYSQL server daemon must have write privilege to $_SERVER['DOCUMENT_ROOT']/data.txt. And this directory must be accessible.

Upvotes: 1

Related Questions