字符编码php mysql [英] Character encoding php mysql

查看:143
本文介绍了字符编码php mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,其中数据存储像boîtes与无utf8字符。现在我有我的php脚本在我的本地机器上正常工作。

I have a table where the data are stored like boîtes with none utf8 characters. Now I have my php script which works fine on my local machine.

$utf = utf8_decode($details);
echo "UTF8-DE : ".$utf."<hr>";-> `boîtes`

当我把这个脚本放在另一台机器上时,它不工作它的回声boîtes。我确信它取决于php或服务器的字符集?任何帮助

When I put this script on another machine its not working its echoing boîtes . I am sure it depends on the charset of the php or server? Any help please

推荐答案

尝试 set_charset 函数

mysqli_set_charset($connection, "utf8");



For mySql



For mySql

mysql_set_charset("UTF8", $connection);



替代



Alternative

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_unicode_ci'");

这篇关于字符编码php mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆