我的代码是这样的..
$host = "localhost";
$user = "root";
$password = "";
$database = "db1";
$port = "3306";
$socket = "";
try {
mysqli_connect($host, $user, $password, $database, $port, $socket);
echo 'Connected to database';
} catch (mysqli_sql_exception $e) {
echo $e->errorMessage();
}
答案 0 :(得分:1)
你必须使用
$link = mysqli_connect($host, $user, $password, $database) or die("Error " . mysqli_error($link));