I had the same problem when I did the following:
<?
if ($submit)
{
$res=mysql_query("INSERT INTO table(name) VALUES('$name')",$mysql_link);
}
?>
<form action=PHPSELF>
<input name=name value="<? echo $name ?>">
<input type=submit name=submit>
</form>
The name field is returned as \'Peter\' after one run.
<input name=name value="<? $name=stripslashes($name); echo $name; ?>">
Did the trick for me.