Character Encoding problem?

空扰寡人 提交于 2019-12-24 03:34:38

问题


In my mysql database I have the following information in a page name field.

ç,Ç,ö,Ö,ü,Ü,ı,İ,ş,Ş,ğ,Ğ

If I do a phpmyadmin dump the above is exported.

I am using a different php script and instead of the above I am getting this.

"ç,Ç,ö,Ö,ü,Ü,ı,İ,ş,Ş,ğ,Ğ"

This is the snippet which is generating the output.

$data_sql = "SELECT * FROM ".$table_name;
$data_res = @mysql_query($data_sql);


while($data_row = @mysql_fetch_array($data_res,MYSQL_NUM))
{
 print_r($data_row);
}

How can I modify this to make sure that the data is correct? Is some sort of php function required? Do I need to do something to the file?

Any advice is much appreciated.


回答1:


You can set client encoding this way:

mysql_connect();
mysql_select_db("database");
mysql_query("SET CHARACTER SET utf8");



回答2:


See this please. You need UTF8 format.




回答3:


No, this code doesn't change your symbols. you do it somewhere else

Edit: now, after your edit, it become clear that you haven't proper encoding set. SET NAMES should help



来源:https://stackoverflow.com/questions/2537740/character-encoding-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!