stone140 Posted October 12, 2006 Share Posted October 12, 2006 When I am retrieving a "text" field from my mysql database the new lines (that the user entered) are no longer there when I display the field. It is simly one continual line of text. Has anyone ever run into this problem before - if so how did you fix it? Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted October 12, 2006 Share Posted October 12, 2006 If the user posted/entered the text (like a comment or so) using a <textarea> on your page the linebreaks will disappear if you just insert $_POST['text'] into your mysql-database. Instead you should insert nl2br($_POST['text']). This will preserve the linebreaks... Quote Link to comment Share on other sites More sharing options...
stuart.cole Posted October 12, 2006 Share Posted October 12, 2006 I had exactly the same issue recently - If you read this post you can see the help I received - which I have now got working[url=http://www.phpfreaks.com/forums/index.php/topic,111288.0.html]Check out huggies answer...[/url] Quote Link to comment Share on other sites More sharing options...
alpine Posted October 12, 2006 Share Posted October 12, 2006 [quote author=Wuhtzu link=topic=111335.msg451113#msg451113 date=1160684713]If the user posted/entered the text (like a comment or so) using a <textarea> on your page the linebreaks will disappear if you just insert $_POST['text'] into your mysql-database. Instead you should insert nl2br($_POST['text']). This will preserve the linebreaks...[/quote]It is much better practice to use nl2br() when outputting data Quote Link to comment Share on other sites More sharing options...
stone140 Posted October 12, 2006 Author Share Posted October 12, 2006 You guys are lifesavers. Thanks! 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.