<?php
header("content-type: text/html;charset=utf-8");
$mysqli=new mysqli ("localhost","root","root","数据库名");
if($mysqli->connect_error){
die ("连接失败".$mysqli->connect_error);
}
$sql="select * from 表名";
$res=$mysqli->query($sql);
while($row=$res->fetch_row()){
foreach($row as $key=>$val){
echo"--$val";
}
echo"<br/>";
}
$res->free();
$mysqli->close();
?>
------解决方案--------------------
mysql字段用的什么编码
页面编码与之 一致。
------解决方案--------------------
- PHP code
header("content-type: text/html;charset=utf-8"); $mysqli=new mysqli ("localhost","root","root","数据库名"); if($mysqli->connect_error){ die ("连接失败".$mysqli->connect_error); } $mysqli->query('SET NAMES utf8'); //加上这一行 ...
------解决方案--------------------
页面 数据库操作 数据库 三方面 编码一致
1.Mysql 字段属性 utf8_general_ci
2.mysql_query("set names 'utf8'");
3.<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />