在读取数据时发现中文的部分是“?”,可是在设计数据库时的编码都是设成了utf8,PHP读取MySQL数据出现问号前代码
$sql = "select * from sc_user where accounts = $accout and password = $password ";
$result = $conn->query($sql);
$row = mysqli_fetch_assoc($result);
解决后,就是加多了一行**$conn->query(“set names ‘utf8’”);**
$sql = "select * from sc_user where accounts = $accout and password = $password ";
$conn->query("set names 'utf8'");
$result = $conn->query($sql);
$row = mysqli_fetch_assoc($result);