kevincro Posted December 3, 2007 Share Posted December 3, 2007 I have a form that contains a textarea, the form is processed using php and is saved into a MySQL database field. The DB field is a text area. The problem that I have is no matter how the user enters the info, it is saved without any paragraphs or line breaks. How do I over come this. Thank you KC Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 3, 2007 Share Posted December 3, 2007 Use nl2br() on the data coming out of the database www.php.net/nl2br Quote Link to comment Share on other sites More sharing options...
kevincro Posted December 3, 2007 Author Share Posted December 3, 2007 I might have not understood the information on the linked page, but does that mean that \n would have to be inserted when the form is filled out. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 3, 2007 Share Posted December 3, 2007 No, when a user enters data into a textarea, linebreaks are transmitted as the "\n" characters. When this data is displayed in a browser, the browser does not interpret the "\n" to be a line break, so you need to use the nl2br() function to add the <br> tag after each "\n" character. Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.