If you are using the MySQL extension, use [man]mysql_real_escape_string/man on string values to ensure that the incoming data is properly escaped.
If you are using the MySQLi or PDO extensions, use prepared statements.
I suggest using the PDO extension if you can.