Jump to content

Archived

This topic is now archived and is closed to further replies.

stone140

Problem with text format pulling from mysql field

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.