header("content-type:text/html;charset=utf-8"); @mysql_connect('localhost','xuexi','123456') or die('数据库连接失败'); mysql_select_db('xuexi') or die('数据库连接失败'); //mysql_query('set name utf8'); mysql_query("SET NAMES 'utf8'"); $sql='select* from a'; mysql_set_charset('utf8'); $query=mysql_query($sql); while($row=mysql_fetch_array($query)) { print_r($row); }