Hey all,
I've been trying to solve this one problem I'm having with a form and a MySQL database.
When a user enters information in a 'textarea' with physical wrap on my form, all of the carriage returns are lost producing one very, very long line of text when the info is recalled from the db.
I've done a bit of searching on the net and came across the command: $string = nl2br ($string); ... but this doesn't do anything (I'm probably using this command incorrectly). Should I use this command before I shoot the info onto the db or should this command be used when retrieving the text? Will this command even solve the problem?
Essentially, I want to store information in a format which resembles messages stored on a forum.
Any suggestions?
Keeping the format of a text field in a MySQL database...
Moderator: General Moderators
-
Cynical Drunk
- Forum Newbie
- Posts: 1
- Joined: Sun May 05, 2002 3:49 pm
After you get the string from the database, you do something like this:
That will turn all carriage returns into <br />'s
Code: Select all
$string = nl2br($string);
echo $string;