话不多说上代码
<html>
<head>
<title>选择MySQL数据库</title>
</head>
<body>
<?php
$link = mysqli_connect("localhost", "root", "root");
$db_selected=mysqli_select_db("sssjk",$link);
//$db_selected=mysql_query("use db_database16",$link);
if($db_selected){
echo "数据库选择成功!";
}
?>
</body>
</html>
很遗憾,报错,这就是赤裸裸的现实!我们看下错误信息如下:
Fatal error: Uncaught TypeError: mysqli_select_db(): Argument #1 ($mysql) must be of type mysqli, string given in E:\web\apache2.4\htdocs\456.php:8 Stack trace: #0 E:\web\apache2.4\htdocs\456.php(8): mysqli_select_db('sssjk', Object(mysqli)) #1 {main} thrown in E:\web\apache2.4\htdocs\456.php on line 8