What functions should I use to encode / decode / escape / stripslash data for the following purposes?
- when calling a PHP script from JS like:
page.php?data=don't_use_#_and_%_in_URL_params - when a PHP script receives a parameter from JS like:
don%27t_use_%23_and_%25_in_URL_params - when starting a MySQL query from PHP with data previously received from JS to prevent MySQL injections (let's say I need to insert the following sequence of characters into the database:
"``' ) - when I need to compare the value of the field containing the sequence
"``' with the expression in the MySQL statement - when I need to get the value of a field from a MySQL table and the field contains a
"``' and I want to use it in a PHP macro cable eval () - when I need to send data from PHP to JS in AJAX response and contain
"``' characters - and finally i need eval () the previous answer in JS
something like this diagram:
JS (encode) β (decoding) PHP (encoding) β (decoding?) MySQL (encoding?) β (decoding) MySQL (encoding) β (decoding) JS
if anyone has the time and pleasure to answer, or correct me, if I made any mistakes here, thanks in advance
source share