Page 1 of 1
force line break
Posted: Fri Jul 16, 2004 10:40 pm
by fresh
hey, I need to force a line break upon each entry to this text file:
Code: Select all
$dis = $_SESSION['usernam'];
$fp = fopen("winners/win06.txt","ab");
fputs($fp,$dis."\n");
fclose($fp);
you can see what I tried, it's not working... right now it's writing everything on one line, I really need them to go on seperate lines for each entry... thanks
edit: fixed the code to represent new code being used. however, it still has problems...

Posted: Fri Jul 16, 2004 10:41 pm
by d3ad1ysp0rk
fputs($fp,$_SESSION['username'] . "\n\r");
Posted: Fri Jul 16, 2004 10:41 pm
by John Cartwright
wuts wrong with
fputs($fp,$_SESSION['username'] . "\n\r");
Posted: Fri Jul 16, 2004 10:50 pm
by fresh
not working... it's not even writing to the file now??? hmmm any help???

Posted: Fri Jul 16, 2004 10:52 pm
by d3ad1ysp0rk
Errors? More code? etc?
Posted: Fri Jul 16, 2004 10:56 pm
by fresh
ok, got it going to the next line, but it's throwing a block [] in front of the names, how to get rid of that please??
Posted: Sat Jul 17, 2004 10:51 am
by Buddha443556
fresh wrote:ok, got it going to the next line, but it's throwing a block [] in front of the names, how to get rid of that please??
That's your text editor. It doesn't (fully) recognize the unix line breaks. You maybe able to adjust your text editor's settings to compensate?
Posted: Sat Jul 17, 2004 12:24 pm
by markl999
Wouldn't it be \r\n not \n\r ?
how
Posted: Sat Jul 17, 2004 6:18 pm
by fresh
would my text editor have anything to do with it??? I mean the blocks are added by the server, not the editor... hearing that, could it still be my editor??
Posted: Sat Jul 17, 2004 6:31 pm
by kettle_drum
What text editor are you using? As i know that notepad doesnt recognise \r\n and displays the block that your talking about.
...
Posted: Sat Jul 17, 2004 7:46 pm
by fresh
Im using hapedit, it's free and I like it, pretty good for new people... I am writing to text files, which were generated by notepad, is that what you guys are talking about?? I used some trim code, that someone gave me, and it works good now, after rearranging my logic on each page... thanks

Posted: Sat Jul 17, 2004 8:24 pm
by feyd
notepad only works off \r\n or 0x0A 0x0D in hex. If only 1 is there, you'll get a nice continuous line with the block like characters (at best)
huh
Posted: Sat Jul 17, 2004 8:42 pm
by fresh
what are we talking about??? It's because I'm using a txt file to store plain text chars, and when I sent the \n to it, the server added the [], since I uploaded them as empty files... it had to be the server... however, someone gave me a really good script that strips each [] off each line, and so far seems to be workin ... thanks
