Home > Backend Development > PHP Tutorial > 如何获取mysql中枚举类型的值呢?

如何获取mysql中枚举类型的值呢?

WBOY
Release: 2016-06-23 14:23:18
Original
1952 people have browsed it

mysql php utf8 数据库

Array ( [0] => 1 [1] => storylok [2] => lele1989 [3] => ? )
为什么获取到的这个枚举类型是问号呢? 我在mysql控制台看的确是中文字呢。 字符集PHP和mysql都是utf8,怎么获取到这个枚举类型的值。

<?phpheader ( "Content-Type:text/html; charset=utf-8" ); $host = "localhost";$user = "root";$password = "";@$conn = mysql_connect($host,$user,$password) or die("数据库连接失败,请检查数据库配置!" . mysql_error());$tableName = "viuoo";mysql_select_db($tableName,$conn) or die('数据库表选择出错,请检查数据库表名是否正确!');mysql_query("SET NAMES 'utf-8'");$dm = "SELECT * FROM  user";$result = mysql_query($dm,$conn);while($res = mysql_fetch_row($result)){	print_r($res);	}?>
Copy after login

回复讨论(解决方案)

mysql_query("SET NAMES 'utf-8'");

修改成

mysql_query("SET NAMES 'UTF8'");

晕死,太感谢了!我就纠结半天了。也不是字符问题 也不是数据库问题! 太感谢你了。结果没注意这个问题。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template