<?php
$con=new mysqli("localhost:3306","root","root","mysql")
or die("connect failed!<br>");
$con->query("set names gbk");
$sql="select * from mysql.test ";
$sql=$sql."where 成绩=95";
$result=mysqli_query($con,$sql);
if($result)
{
echo"query successed!<br>";
$array=mysqli_fetch_array($result,MYSQLI_NUM);
if($array)
{
for($k=0;$k < count($array);$k++){
echo"data queryed:\n".$array[$k];
}
}
}
else
echo"query failed:<br>"
?>
为什么我输出来的中文都是乱码啊,如果我把$con->query(“set names gbk”);的gbk改成utf8就直接query failed,求大佬解答