Problem Creating an Saving CSV-file -- on a client

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Nomistake
Forum Newbie
Posts: 15
Joined: Sat Oct 02, 2010 11:16 am

Problem Creating an Saving CSV-file -- on a client

Post by Nomistake »

Hi,
Good evening.
I have been coding a page which generates an csv file. Al works fine on my pc, but when i upload the page, i get these errors:

failed to open stream: No such file or directory in <b>/usr/www/users/...
failed to open stream: Permission denied in <b>/usr/www/users/...

Now, as i have read on the www it has something to do with persmission and the persmissions should be changed on the hosting server.

Now, is the any other way to generate and save the csv-file on client side? so that i dont need to create it on the server first?
I'm reather new to php so some good advice would be welcome.

This is part of the code i use to generate the csv file: ...

Code: Select all

<?php
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename="gmail.csv"');
readfile('gmail.csv');
//----------------------------------------------------------------------------------------------------- define mailing list
//----------------------------------------------------------- connect to database
@mysql_connect($server,$username,$password);
@mysql_select_db($database) or die( "please login first");
@$query = "SELECT * FROM personen WHERE status='1'";
$result = mysql_query($query);
mysql_close();
//------------------------------------------------------------------ query array
$list = array();
$list[0] = array(.....);
$i = 1;
while ($personen_array = mysql_fetch_array($result)){
	$list[$i] = array (..........);
	$i++;
}
$fp = fopen('gmail.csv', 'w');
foreach ($list as $fields) {
    fputcsv($fp, $fields);
}
fclose($fp);
?> 
Anyone? 8O
Post Reply