Say, for example, you have the following variable:
$name = 'Richard "Rich" Alloway';
Now, we can agree that $name now contains:
Richard "Rich" Alloway
In order to safely convert this to something which can be placed into a SQL statement, you need to use the addslashes() function:
$name = addslashes( $name );
This will populate $name to contain data like this:
Richard \"Rich\" Alloway
The variable is now safe to use.
In order to convert the variable back to it's non-slashed form:
$name = stripslashes( $name );
Hope this helps!
-Rich