Jump to content

Problem with text format pulling from mysql field


stone140

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.