Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:46:41+00:00 2026-06-15T20:46:41+00:00

I have a form that inserts blob text into a database. When i insert

  • 0

I have a form that inserts blob text into a database.

When i insert it into the database using a textarea, it works fine.

For example, if i put this text into the textarea field:

test


ss
f



f
f




dsdfdsf


sdfsdfsdf

it saves it into the database as:

test


ss
f



f
f




dsdfdsf


sdfsdfsdf

So thats fine, now when i fetch the data from the database and echo it onto a div, i use nl2br(), and the divs content becomes:

test


ss
f



f
f




dsdfdsf


sdfsdfsdf

So thats still fine

HOWEVER

If i echo the output from the database into a textarea, it becomes:

test
ss
f
f
f
dsdfdsf
sdfsdfsdf

That is not using nl2br, if i do use nl2br, the textarea becomes:

test<br /><br /><br />ss<br />f<br /><br /><br /><br />f<br />f<br /><br /><br /><br /><br />dsdfdsf<br /><br /><br />sdfsdfsdf

And i want new lines, not (br /), you can see it knows how many lines there should be, but when i dont use nl2br, it will only do up to 1 new line in a row.

Ive tried googling around, and all i can find is people asking how to echo the database content to a div, but for me, it works fine to a div (with nl2br), its just to a textarea…

Ive also tried giving the textarea the css attribute: ‘white-space: pre;’, but that doesnt work either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:46:43+00:00Added an answer on June 15, 2026 at 8:46 pm

    You can’t use nl2br if you are outputing the data into a textarea. Just output the data (with htmlspecialchars).

    The textarea will see the \n (newlines) as a div will see <br />.

    http://jsbin.com/uzinut/1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form that inserts data into a database using foreach($_POST as
I have a form that inserts data into my DB using AJAX and PHP.
I have a web form that inserts a row into an SQL Server 2008
I have a Greasemonkey script that dynamically inserts an HTML form into some web
I have a form that is trying to insert some data into an SQL
I have a simple .net windows form which inserts user input into sql database.
I have an ASP.NET page with a form that inserts to a database. The
Hi i have a form (X) that inserts data into a mysql table (A)
I have a script im writing that inserts a record into my DB using
Using Doctrine DBAL, I have some code that inserts a new row into the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.