Saving Textarea to text 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
austellpgrammer
Forum Newbie
Posts: 1
Joined: Sun Apr 09, 2006 3:08 pm

Saving Textarea to text file

Post by austellpgrammer »

When I save textarea to my text file, it does not save correctly.

textarea as entered in the form.
line 1
line 2
line 3

saves as:
|line 1
line 2
line 3|

It's trying to save as it was entered but each line in the text file represents
a seperate record.

If I have the following fields:
$username
$notes (textarea)
$date

It will display in the text file as:
John Doe||03/09/06
Jane Doe||03/09/06
James Doe|line 1
line 2
line 3|03/09/06

So now when I list the first record (name) in the text file, I get:
John Doe
Jane Doe
James Doe
line 2
line 3

Help, newbie here wasted three days on this.
Doing the same on PHP 4 and PHP 5.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use addslashes(), or a similar function to convert the textarea into a single line string.
Post Reply