Page 1 of 1

carriage returns in a message board

Posted: Thu Jun 06, 2002 8:43 pm
by Goat
Here's my situation...

I've written a PHP and MySQL based message board and it works out fine. Messages post and they are retrieved and it all goes spectacular. My only problem is that when a message is retrieved from the database it loses all the carriage returns placed within the message. Either that, or the carriage returns aren't being sent to the database in the first place. I've debated over it for a while, how can I fix this?

Posted: Thu Jun 06, 2002 10:28 pm
by jason
When you go to display the post, use the nl2br function

http://www.php.net/nl2br

Code: Select all

echo nl2br($string);

Posted: Thu Jun 06, 2002 11:02 pm
by Goat
sure enough, that fixed it! thanks!