Home >Backend Development >PHP Problem >PHP failed to connect to database server

PHP failed to connect to database server

藏色散人
藏色散人Original
2019-11-02 09:13:543841browse

PHP failed to connect to database server

php failed to connect to the database server?

conn.php代码如下:

<?php
//连接MySQL服务器,选择数据库
$conn=mysqli_connect("localhost", "root", "root", "cloth_system") or die("连接数据库服务器失败!".mysqli_error());
//设置数据库编码格式utf8
mysqli_query($conn,"set names utf8");
?>

index.php代码如下:

......
<!--top-->

<!--main-->
<?php
include_once("conn/conn.php"); //连接到数据库
?>

Solution:

Run conn.php directly to see the error message, and then make corresponding modifications based on the error message.

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of PHP failed to connect to database server. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn