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

PHP failed to connect to database server

藏色散人
Release: 2023-02-28 10:22:01
Original
3844 people have browsed it

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"); //连接到数据库
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template