作者:我我檬檬我我186 | 来源:互联网 | 2023-05-17 03:05
mysqli因为默认是latin-1编码,当你的页面时utf-8编码是,就会产生页面乱码问题。mysqli乱码解决办法:$mysqlinewmysqli(loca
mysqli因为默认是latin-1编码,当你的页面时utf-8编码是,就会产生页面乱码问题。
mysqli乱码解决办法:
$mysqli = new mysqli('localhost','root','password','dbname');//mysqli链接数据库的写法
//$mysqli->query("SET NAMES utf8");//写法一
$mysqli_query($db,"SET NAMES utf8");//写法二
1)mysql乱码解决办法同上(原理相同):
$db =mysql_connect("localhost","root"," password ") or die("unable to connect");
//$db->query("SET NAMES utf8");//写法一
mysql_query($db,"SET NAMES utf8");//写法二