连接

$con=@mysqli_connect($host,$user,$pass,$dbName,$port);
#检测错误
if(empty($con)){die( mysqli_connect_error());}

查询

$sql="select * from test";
$res=mysqli_query($con,$sql);
if(!$res){die('error query sql:'.$sql);}
while($row = mysqli_fetch_assoc($res)){
    var_dump($row)
}