加了mysql_query("SET NAMES 'UTF8'"); 网页上还是显示乱码
<?php
$link = mysql_connect('127.0.0.1:3307','root', 'root') or die('数据库连接失败');
mysql_select_db('phpdata');//选择一个数据库
mysql_query("SET NAMES 'UTF8'");
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo '数据库连接成功';
$selectSql = mysql_query('select * from phpfrom');
$row = mysql_fetch_array($selectSql);
var_dump($row);
?>
这是数据:--鏁版嵁搴撹繛鎺ユ垚鍔焌rray(10) { [0]=> string(1) "1" ["id"]=> string(1) "1" [1]=> string(6) "灏忓皬" ["name"]=> string(6) "灏忓皬" [2]=> string(2) "12" ["age"]=> string(2) "12" [3]=> string(19) "2019-05-31 16:11:42" ["crDate"]=> string(19) "2019-05-31 16:11:42" [4]=> string(19) "2019-05-31 16:11:48" ["upDate"]=> string(19) "2019-05-31 16:11:48" }