Re: [PHP-DB] export to csv file

2002-09-29 Thread Michael GARGIULLO

You need to specify a path that the webserver has write permissions to. 
Yes this can be bad, so be careful.  I have a script that grabs data 
from2 databases and writes the report out to a csv file, which the 
browser then downloads.



- Original Message -
From: Diana Castillo <[EMAIL PROTECTED]>
Date: Saturday, September 28, 2002 10:02 am
Subject: [PHP-DB] export to csv file

> Hi, I want to export some fields on a regular basis from a table 
> to a text
> file, preferable to the users local computer. I tried writing to a 
> file with
> fopen but I get "permission denied" when I try to open it for writing.
> What is the best solution?
> Thanks,
> Diana
> 
> --
> See my web page:
> http://www.netrox.net/%7Ecastillo/hghindex.htm
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] export to csv file

2002-09-28 Thread Peter Lovatt

If you are using *nix set the file, or directory permissions recursively, to
777.

If you want to let the users download the file it may be simpler to generate
the content and send it directly to them when they click on a link.

http://www.phpbuilder.com/mail/phplib-list/2001062/0017.php

explains but basically set the header using

header("Content-Type: application/force-download");

and then output the file.

Peter





---
Excellence in internet and open source software
---
Sunmaia
www.sunmaia.net
tel. 0121-242-1473
---

-Original Message-
From: Patrick Latour [mailto:[EMAIL PROTECTED]]
Sent: 28 September 2002 20:42
To: Diana Castillo; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] export to csv file



- Original Message -
From: "Diana Castillo" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 28, 2002 10:02 AM
Subject: [PHP-DB] export to csv file


> Hi, I want to export some fields on a regular basis from a table to a text
> file, preferable to the users local computer. I tried writing to a file
with
> fopen but I get "permission denied" when I try to open it for writing.
> What is the best solution?
> Thanks,
> Diana
>
> --
> See my web page:
> http://www.netrox.net/%7Ecastillo/hghindex.htm
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.391 / Virus Database: 222 - Release Date: 9/19/2002


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] export to csv file

2002-09-28 Thread Thomas Lamy

Diana Castillo [mailto:[EMAIL PROTECTED]] wrote:
> 
> Hi, I want to export some fields on a regular basis from a 
> table to a text
> file, preferable to the users local computer. I tried writing 
> to a file with
> fopen but I get "permission denied" when I try to open it for writing.
> What is the best solution?
> Thanks,
> Diana
> 
It's not clear to me what you want - create a text file on the server, or
create a CSV file for download on the fly...

As fopen() tries to create a local file, it seems you (or better, the uid
owning the web server process) do not have write permission to where you
want to create the file. Your PHP scripts run with the user-id of the web
server, which may be www-data, nobody, wwwrun or whatever. You may have to
ask the server admin to give that process write permission in your diectory.

On the other side it may be better and easier to create a csv file on the
fly. Create a page, say csv-export.php, and link to it using a
href="csv-export.php/export.csv". This way the user's browser is tricked
that the link points to a CSV file, if it does not honor the content-type it
sends (see below).

In csv-export.php you do
http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] export to csv file

2002-09-28 Thread Patrick Latour


- Original Message -
From: "Diana Castillo" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 28, 2002 10:02 AM
Subject: [PHP-DB] export to csv file


> Hi, I want to export some fields on a regular basis from a table to a text
> file, preferable to the users local computer. I tried writing to a file
with
> fopen but I get "permission denied" when I try to open it for writing.
> What is the best solution?
> Thanks,
> Diana
>
> --
> See my web page:
> http://www.netrox.net/%7Ecastillo/hghindex.htm
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.391 / Virus Database: 222 - Release Date: 9/19/2002


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] export to csv file

2002-09-28 Thread John Coder

On Sat, 2002-09-28 at 10:02, Diana Castillo wrote:
> Hi, I want to export some fields on a regular basis from a table to a text
> file, preferable to the users local computer. I tried writing to a file with
> fopen but I get "permission denied" when I try to open it for writing.
> What is the best solution?
> Thanks,
> Diana
 If you want to do it as a csv file the best way is select  into
outfile '' fields terminated by ',' from 
. this writes to a csv file. now being able to do things
wtih that file depends if you are using a Unix clone you have to watch
the permissions on the file it sounds like that is the problem . perhaps
add yourself to the mysql group if the file has group permissions. the
last is just a thought.

John Coder


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] export to csv file

2002-09-28 Thread Diana Castillo

Hi, I want to export some fields on a regular basis from a table to a text
file, preferable to the users local computer. I tried writing to a file with
fopen but I get "permission denied" when I try to open it for writing.
What is the best solution?
Thanks,
Diana

--
See my web page:
http://www.netrox.net/%7Ecastillo/hghindex.htm



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php