一般情况下连接mysqli报如下错误:Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host 'localhost:3306' (1) in...是因为连接mysql的语法不对。
localhost:3306这种是mysql的写法,而mysqli的写法如下:
$mysqli = new mysqli("localhost", "user","password","database", "3306"); //port is a string!
端口跟主机是分开的两个参数,所以要记住这一点。