PHP: Updating with öäå into MySQL

China☆狼群 提交于 2019-12-25 08:33:24

问题


I already have done this:

mysql_set_charset("utf8",$link); at the connection

mysql_query("SET NAMES 'UTF8'"); at the connection + on every table in database

changing from latin1 to utf8 collation + character for every table + columns

file have meta utf8 + header('Content-Type: text/html; charset=utf-8'); plus the files itself are formatted in utf-8( without bom)

where link is mysql_connect(), it shows the öäå characters fine when i take them out from database, but when i try to mysql_query UPDATE with stuff, that contains ÖÄÅ, it stores as Ã?¶à .. How can i fix this?

In the database the columns and so are, latin1_swedish_ci, as said it INSERT ÖÄÅs without problem, and echo it out too very well, but not when i try to UPDATE SET $user = 'ööö'


回答1:


mysql_query("SET NAMES 'UTF8'") on every table in database

can you be more specific? I see no way to use this query on every table.

it stores as �¶à ..

how do you check it?




回答2:


In the database the columns and so are, latin1_swedish_ci

This is your problem. You need to use a UTF-8 character set to store UTF-8 data.

What you are showing: �¶à is most likely UTF-8 data (which can consist of multiple bytes) being stored in a latin1 table.



来源:https://stackoverflow.com/questions/3644359/php-updating-with-%c3%b6%c3%a4%c3%a5-into-mysql

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