Is there a Mysql command (or PHP function) that can modify a string before being inserted to the database.

I am having problems with single/double quotes and commas.