Answer the question
In order to leave comments, you need to log in
How to save to db \n?
Good afternoon!
I need to save and display a multi-line string (textarea) from the database. How to do it right?
Now when sending:
1) I pass the string (HTML->JS->PHP) via fetch
2) I get the string (PHP) via $_GET, I write the data to the database (INSERT)
Now when I receive it:
1) I make a request (JS->PHP ) via fetch
2) receive and return (PHP->MYSQL->PHP) - print_r(json_encode($res, JSON_UNESCAPED_UNICODE))
3) output to textarea(PHP->JS->HTML)
Everything works, but when outputting multiline text hyphens are lost (all in one line). How to correctly display multiline text?
Answer the question
In order to leave comments, you need to log in
\n is as much a part of a string as text, so watch where it gets lost. I suspect it's around here
json_encode
I get a string (PHP) via $_GET, I write data to the database (INSERT)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question