how to replace special charracters

From the form input I have some data which is inserted into database ,
and this data may have some special characters which can cause problems
in other parts of the system. Now before inserting into db, how can I
replace those characters with acceptable chars? Is there a standard way
to replace double quotes with single quotes, slash with hyphen etc.?

Look into Tidy...