S
S
serzhb2012-07-16 16:49:55
JavaScript
serzhb, 2012-07-16 16:49:55

TEXTAREA-> JSON -> PHP -> MySQL -> PHP -> JSON -> TEXTAREA?

Hello!
Suppose the user enters data in TEXTAREA, then this data is sent using AJAX (JQuery) in JSON format to a PHP script, which in turn saves this data in the MySQL database.
Then, when working with a web application, a person can re-request this data through the same chain back to the textarea.
The question is that a lot of problems arise with "problem" characters: quotes and line breaks (in Javascript). Is there any universal solution that allows you not to lose a single character in this chain, not to cause errors anywhere and return the text saved on the server in its original form?
I tried to save the string in escape, but there is still a problem with quotes, when the quote is at the end - it is cut off.
utf-8 encoding everywhere.
Can you please tell me the best solution or give a link where you can read about it?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Malerok, 2012-07-16
@Malerok

json_encode|decode, htmlspecialchars, no?

F
freeek, 2012-07-16
@freeek

Here , for example.
Well, there, based on this, you can google :)

A
Anatoly, 2012-07-16
@taliban

You did something wrong, I always encode such data with encodeURIComponent and there were no problems. Although if everything is so bad for you, get yourself a dictionary with problematic symbols and replace them with your hands.

S
shagguboy, 2012-07-16
@shagguboy

and at what stage the characters are lost?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question