mysqli_select_db() 期望参数 1 是 mysqli,给定字符串
我是Mysqli_*的新手,但收到以下错误:
警告:mysqli_select_db() 要求参数 1 为 mysqli,D:\Hosting\9864230\html\include\connection.php第 11 行给出的字符串
警告:mysqli_error() 正好需要 1 个参数,D:\Hosting\9864230\html\include\connection.php 在第 13 行给出 0
数据库选择失败:
<?php
require("constants.php");
// 1. Create a database connection
$connection = mysqli_connect(DB_SERVER,DB_USER,DB_PASS);
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
// 2. Select a database to use
$db_select = mysqli_select_db(DB_NAME,$connection);
if (!$db_select) {
die("Database selection failed: " . mysqli_error());
}
?>