I just have done test to see if my aplication can handle special charcters.
In PHP form I add data to MySQL as folow:
"test"
| 'test'
| " £ $ % ^ & * ( )
| 'test' "test"
data have been escaped and in MySQL looks like this:
\\\"test\\\"
| \\\'test\\\'
| ! \\\" £ $ % ^ & * ( )
| \\\'test\\\' \\\"test\\\"
that goes to JSON like that:
[
"\\\\\\\"test\\\\\\\"",
"\\\\\\\'test\\\\\\\'",
"! \\\\\\\" £ $ % ^ & * ( )",
"\\\\\\\'test\\\\\\\' \\\\\\\"test\\\\\\\"",
]
that can't be parset in JSON so I checked above in JSONLint.com and I get that error:
Parse error on line 2:
..."test\\\\\\\"", "\\\\\\\'test\\\\\\\
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
I know that can be fixed but not sure where?
- in PHP before I send to MySQL?
- in MySQL query before sent to MySQL database?
- in PHP before goes to JSON?