我安装了xampp 开启apache和mysql。 在htdocs文件夹中粘贴了“ phpproject”。 转到浏览器并输入---> http://localhost/phpproject/ 在浏览器中收到警告--->警告:mysqli_connect():(HY000 / 1045):在C:\ Users \ xampp \ htdocs \中拒绝用户'YOUR DB NAME'@'localhost'的访问(使用密码:NO)第8行上的phpproject \ db.php
警告:mysqli_error()期望恰好有1个参数,第9行的C:\ Users \ xampp \ htdocs \ phpproject \ db.php中给出的参数为0 无法连接到mysql,因为
C:\ Users \ xampp \ htdocs \ phpproject \ db.php中的代码
`
$dbhost = 'localhost';
$dbuser = 'YOUR DB USER';
$dbpass = 'YOUR DB PASS';
$dbname = 'YOUR DB NAME';
$con=mysqli_connect($dbhost,$dbuser, $dbpass,$dbname) //connect to the database server
or die ("Could not connect to mysql because ".mysqli_error());
mysqli_query($con, "SET NAMES 'utf8'");
mysqli_select_db($con,$dbname) //select the database
or die ("Could not select to mysql because ".mysqli_error());
?> `