force line break

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
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

force line break

Post 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... :)
Last edited by fresh on Fri Jul 16, 2004 11:16 pm, edited 2 times in total.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

fputs($fp,$_SESSION['username'] . "\n\r");
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

wuts wrong with

fputs($fp,$_SESSION['username'] . "\n\r");
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

Post by fresh »

not working... it's not even writing to the file now??? hmmm any help??? :)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Errors? More code? etc?
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

Post 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??
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post 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?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Wouldn't it be \r\n not \n\r ?
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

how

Post 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??
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

...

Post 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 :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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)
Last edited by feyd on Sat Jul 17, 2004 8:53 pm, edited 1 time in total.
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

huh

Post 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 :)
Post Reply