PHP - big trouble escaping “\”

Super

New Member
I try to explain my problem with a non-perfect english :)When i try to send some string (client side) to the server, i see that the HTML Form add the "\" char as escape before some chars (for example with ", ' and \ itself).But this is a problem : if save it on mysql, before i filter the string using mysql_real_escape_string(), and it considers the escape char added by html as a "char added by the user". But that's not true.The same when, after I checked the value on server-side and ignore it for some reason, i place them on the fields. I need to escape the chars again (i do it with addslashes() php function), because if i have $var equal to hello "world" how are you, on the input field (as i wrote above) it fails.So, how can I fix this problem? I think there's a solution :)Part 2Now, with magic_quotes i've resolved this problem. Now, if the parameter fails when i check it, i'll save it on a var and put it into the right field. The problem is that.\[code\]<script type="text/javascript"> $(document).ready(function() { $("#input1").val("<?= addslashes($name) ?>"); });</script> <input class="inputReg" maxlength="20" name="name" id="input1" />\[/code\]this code work!!! I put the value (trought JQuery). If i write this :\[code\]<input class="inputReg" maxlength="20" name="name" value="http://stackoverflow.com/questions/3925856/<?=addslashes($name)?>" id="input1" />\[/code\]it doesnt work. In fact, if i write (for example) the string "hello 'my' name is marco" it add each time 1-2-4-8 the char \ before. Why this? It doesnt works. Any idea? Cheers
 
Back
Top