Question: 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 2

Now, 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.

```
<script type="text/javascript">
    $(document).ready(function() {
        $("#input1").val("<?= addslashes($name) ?>");
    });
</script>       

<input class="inputReg" maxlength="20" name="name" id="input1" />

```

this code work!!! I put the value (trought JQuery). If i write this :

```
<input class="inputReg" maxlength="20" name="name" value="<?=addslashes($name)?>" id="input1" />

```

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

Answer: 
Sounds like [magic quotes](http://php.net/manual/en/security.magicquotes.php). Make sure this is disabled in your php.ini file:

```
magic_quotes_gpc = Off

```
```
mysql_real_escape_string(stripslashes($string))

```

will (temporarily) fix your problem. Turning off magic\_quotes though would be the best option.