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? Link to comment https://forums.phpfreaks.com/topic/23794-problem-with-text-format-pulling-from-mysql-field/ 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... Link to comment https://forums.phpfreaks.com/topic/23794-problem-with-text-format-pulling-from-mysql-field/#findComment-108066 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] Link to comment https://forums.phpfreaks.com/topic/23794-problem-with-text-format-pulling-from-mysql-field/#findComment-108069 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 Link to comment https://forums.phpfreaks.com/topic/23794-problem-with-text-format-pulling-from-mysql-field/#findComment-108072 Share on other sites More sharing options...
stone140 Posted October 12, 2006 Author Share Posted October 12, 2006 You guys are lifesavers. Thanks! Link to comment https://forums.phpfreaks.com/topic/23794-problem-with-text-format-pulling-from-mysql-field/#findComment-108074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.