db_query in drupal insert the values as question marks
when i use db_query in drupal to insert non-english letters (Arabic for example), it appears as question marks in the DB, while if i use mysql_query it works fi开发者_C百科ne !!! any idea about this and how to fix it??
Thanks for your help
thanks all for your attention... i fixed this issue by using mysql_set_charset('utf8',$connection);
I suspect you'll need to set the mysql_client_encoding to use UTF8, although you'll want to check if the table character set and collation, etc. are set to this as well.
i.e.: The table definitions should ideally be of the form...
CREATE TABLE ... (
...
) ENGINE=... DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;
(That said, that will of course use a case insensitive collation, which you might not desire/require.)
In essence, as long as you use UTF8 throughout (front end page encoding, mysql client connection encoding and table collation, etc.) you shouldn't have any problems.
精彩评论