8
I have a textarea
and would like to save the user-made line breaks in the database. For example, user writes the following:
"Lorem Ipsum.
Is simply.
Dummy text.
Of the printing.
And typesetting."
But in the database, it is saved as:
"Lorem Ipsum. Is simply. Dummy text. Of the printing. And typesetting."
I would like it to be written with the breaks of lines made in the textarea.
How can I do it using PHP
?
Line breaks were refused. But in the case, it would skip the line to each point in the example.
– Marcelo
@Antonioalexandre that you said there is nonsense. It is no problem to record line break in VARCHAR. What changes in the text formats for the end user is basically the storage capacity.
– Bacco
The following test shows that Mysql respects the breaks when saving: http://sqlfiddle.com/#! 9/b8938a/1
– Bacco
@Marcelo the problem may not be in the save, but in the fact that you don’t switch to <br> when playing back on screen. You need to test this. If this is the case, you save in DB, but at the time of RECOVER uses the
nl2br
like Miguel said.– Bacco
@Bacco, I checked here and really confused with the input fields that always saved as varchar and textarea that always saved as text. Really varchar accepts yes line break n and said nonsense when he said he did not accept. In input type="text" fields you cannot type line break, but in the database you enter line break even if you are varchar. However insert <br> to break line in the bank is not good practice and in that I was right. Unless it is purposeful as in editing a field used in WYSIWYG editor.
– Antonio Alexandre