Try to set the mysql charset *before* mysql_real_escape_string is used