Page 1 of 1

trouble with fwrite

Posted: Thu Jul 24, 2003 5:18 pm
by psychotomus

Code: Select all

$fp = fopen("emails.txt", "a");
		fwrite($fp,$email);
		fclose($fp);
this is the code i got, it writes to the end of the file, but i cant get it to go to the next line.

ive tried fwrite($fp,"\n".$email); but that just wrote some weird ascii, how can i get it to go the next line and write?

...

Posted: Thu Jul 24, 2003 5:45 pm
by kettle_drum
It should work if you use \n. I know that it works when used with fputs.

fputs($fp, $email."\n");

Posted: Thu Jul 24, 2003 7:21 pm
by psychotomus
i guess it does work, but when i open the text file where it stores the $emails in, it has a little square box and all the entrys are on a single line, i guess it doesnt automaticly line feed it, but uses the squares as seperators for new lines

Posted: Fri Jul 25, 2003 12:58 am
by Tubbietoeter
try this:

fputs($fp, $email."\r\n");

...

Posted: Fri Jul 25, 2003 1:07 am
by kettle_drum
Well it maybe because what ever OS your reading from has a different line break code and so \n doesnt break to a new line.