On the site from <textarea> take text with line breaks. In postgresql it is inserted in one line. How to insert text into a database with line breaks from <textarea> ?

  • It all depends on how you insert and test them now. It depends on where you lose the line breaks and whether you lose them at all. Maybe they are normally inserted, you just do not visually see them in postgresql . - Alex Krass
  • Using js ($ ("# input"). Val ()) line is inserted into the database. - Vlad
  • one
    The expression $("#input").val( ) just receives the string and by itself inserts nothing. And even more so, JS on the client does not know how to work with the database, there should at least be another layer of server code. For the solution, you are interested in the complete code stack from the beginning to the end, including how you check. At least a minimal example, otherwise it turns out that you have to guess that you have one of a thousand options. - Alex Krass
  • I pass the value of the field using HTTP POST to the file.php, which is inserted into the database (insert into table values ​​('Field Value') - Vlad
  • one
    @Vlady Never paste the text directly into the query and then there will be no problems with what data and also with sql injections. Always use prepared queries and variable bindings with data php.net/manual/ru/mysqli-stmt.bind-param.php - Mike

0