You need to escape out the string before inserting it into the MySQL database other wise you will get errors.
Simply running add a line that does....
$string_variable = AddSlashes($string_variable);
Before you insert it into the database should help you out.