<?php
header("content-type:text/html;charset=utf-8");
if($con = mysqli_connect("localhost","root","123")){
echo "连接成功<br/>";
if(mysqli_select_db("test")){
echo "连接数据库成功";
}else{
echo "连接数据库失败";
}
}else{
echo "连接失败<br/>";
}
?>显示结果如下然而我的数据库在mysql中是存在的请问这是怎么回事??
1 回答
TCircley
TA贡献3条经验 获得超0个赞
<?php header("content-type:text/html;charset=utf-8"); if($con = mysqli_connect("localhost:3306","root","123")){ echo "连接成功<br/>"; if(mysqli_select_db($con,"test")){ echo "连接数据库成功"; }else{ echo "连接数据库失败"; } }else{ echo "连接失败<br/>"; } ?>
自己重新去看了下文档。发现是传少了个参数,不好意思打扰了
添加回答
举报
0/150
提交
取消