Jump to content

Preserving line breaks (Text Area insertation to MySQL)


Recommended Posts

I have a simple form with a text area.

i add 2 line breaks to start a new paragraph and insert it into the mysql database.

 

so i retrieve the post data:

 

$city_desc = $_POST['city_desc'] ;

 

and it will stick all of the data together when i output with php.. i want it to retain the 2 line breaks so they are like new paragraphs... any ideas?

odd are the line breaks are being stored, but when parsed as html they are run together. try echo'ing your content with nl2br()

This is because web browsers ignore white space characters, such as new lines. In order for a new line to appear in a web browser you need use the <br /> tag. nl2br() converts new lines into <br /> tags.

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.