Jump to content

Recommended Posts

Am trying to get the results of a query to export into a CSV file, but all I keep getting is an error message.

 

PHP Code:

$sql = "SELECT * FROM tbl_qualifications INNER JOIN tbl_users ON tbl_qualifications.UserID=tbl_users.ID WHERE tbl_qualifications.QID=24 AND tbl_users.PrefCom=2 INTO OUTFILE '/downloads/file.csv'";

Error message:

Can't create/write to file '\downloads\file.csv' (Errcode: 2)

 

The folder is created, and has permission to write to it. Don't know what's going on??

 

Can anyone help?

Hey,

 

I used this kind of thing to generate a file from an SQL query before. Worked great.

 

header('Content-type: application/x-msexcel; charset=utf-8');

header('Content-Disposition: attachment; filename="somefile.csv"');

 

Then here you echo() all your information.

 

Hope it helps!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.