Ok I understand now. I think your after the addslashes() and stripslashes() functions. e.g
$text = "Test's";
$text = addslashes($text);
$text should now contain Test\'s
Then to turn the \' into ' again use the stripslashes() function the same way. Hope this helps.