carriage returns in a message board

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
Goat
Forum Newbie
Posts: 11
Joined: Mon Apr 29, 2002 11:12 pm
Contact:

carriage returns in a message board

Post 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?
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

When you go to display the post, use the nl2br function

http://www.php.net/nl2br

Code: Select all

echo nl2br($string);
Goat
Forum Newbie
Posts: 11
Joined: Mon Apr 29, 2002 11:12 pm
Contact:

Post by Goat »

sure enough, that fixed it! thanks!
Post Reply