[thelist] writing to a file PHP (csv)

Carl J Meyer cjmeyer at npcc.net
Mon Dec 16 17:26:01 CST 2002


Andrew,

On Mon, 2002-12-16 at 14:42, Andrew Maynes wrote:
> Hi Carl this is the $cc (which was an old example I had that did put CC details
> into a plain text file, held is a password protected dir :p)  Basically what i
> need to do is store the data in a file that then can be imported into Sage (line
> 50 I think).
>
> $cc="$friends_name; $friends_email; $senders_name; $email";
>
> which is adding data on the same row and not returning to create a new row
> (line) as csv file?  for some reason the records are just being inserted on the
> same line
> $FileName="admin/email_list.txt";
>                $fp = fopen($FileName, "a+");
>                fputs($fp, "$cc,\n");
>                fclose($fp);

This looks ok then, assuming you want a semicolon as the field
separator.  In which case you should remove the comma, so your fputs()
call would look like:

fputs($fp, "$cc\n");

I don't know why the records would be inserted on the same line, using
this code the resultant file should look like:

name; email; s_name; s_email
name2; email2; s_name2; s_email2
...

which is correct.

Carl




More information about the thelist mailing list