mysql_select_db()期望参数2是资源,字符串在

时间:2017-02-25 07:36:40

标签: php mysql

我遇到了新的错误

mysql_select_db()期望参数2是资源,第12行的C:\ Apache24 \ htdocs \ login \ check_login.php中给出的字符串 数据库名称不可用!

mysql_select_db(' localhost',' test')或死亡("数据库名称不可用!");

1 个答案:

答案 0 :(得分:0)

<?php
$con=mysqli_connect("localhost","my_user","my_password");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Change database to "test"
mysqli_select_db($con,"test");
mysqli_close($con);
?>