Line breaks dissapear when I write it to file

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
Canole
Forum Newbie
Posts: 2
Joined: Thu May 20, 2004 3:17 pm
Location: Canada

Line breaks dissapear when I write it to file

Post by Canole »

Hello all,

it sounds stupid, I know, but I cannot keep my line breaks from text of a TEXTAREA returned by a POST action. I write my data from the post to a txt file. But even before I write them I print the returned value (from the post) and the line breaks are all gone!!!! Is there not an equivilant value in URL coding to keep line breaks when posting from one form to another.

To give more details, my first page is a regular HTML used to get info from user. I then post this form to a php page that retrieves the values and writes it to a txt file and displays the info transmitted on the page. I have a link to another page that displays all info written to the txt file. All the info is there but the darn line breaks, especially the ones from a textarea input type on the HTML page. They don't follow to the php page.

I tried to set the set_magic_quotes_runtime function to 0, no effect. I tried to inpose a lenght on the fwrite function, that was no good. Using stripslashes function or not does nothing for me. Do I have to use strtok?

thanks ahead

Canole
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post by xisle »

try <textarea wrap=physical>
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

nl2br() is a function that replaces the line breaks with the <br> tag
Canole
Forum Newbie
Posts: 2
Joined: Thu May 20, 2004 3:17 pm
Location: Canada

Post by Canole »

Thanks every body. the nl2br function is perfect. I also found ereg_replace to help me out here.

thanks again

Canole
Post Reply