PHP 设置MySQL连接字符集的方法

yipeiwu_com4年前Mysql基础
mysql_set_charset()。

这个函数是这样用的:

mysql_set_charset('utf8', $link);
成功返回 TRUE,失败返回 FALSE。

就这么简单。

下面是PHP手册原文
This is the preferred way to change the charset. Using mysql_query() to execute SET NAMES .. is not recommended.

相关文章

Mysql和网页显示乱码解决方法集锦

将数据插入到php?name=%CA%FD%BE%DD%BF%E2" onclick="tagshow(event)" class="t_tag">数据库的时候...

PHP实现基于mysqli的Model基类完整实例

本文实例讲述了PHP实现基于mysqli的Model基类。分享给大家供大家参考,具体如下: DB.class.php <?php //数据库连接类 class...

在mysql数据库原有字段后增加新内容

复制代码 代码如下:update table set user=concat(user,$user) where xx=xxx;...

Mysql数据库操作类( 1127版,提供源码下载 )

Mysql.class.php 下载 复制代码 代码如下: <?php class Mysql { private $db_host; //主机地址 private $db_use...

PHP使用PDO创建MySQL数据库、表及插入多条数据操作示例

本文实例讲述了PHP使用PDO创建MySQL数据库、表及插入多条数据操作。分享给大家供大家参考,具体如下: 创建 MySQL 数据库: <?php $servernam...