How to solve the problem of php database connection error

藏色散人
Release: 2023-03-04 21:28:02
Original
3564 people have browsed it

php database connection error is because PHP7.0 has abolished the "mysql_connect" function. The solution is to use the "mysqli_connect" function to connect to the database.

How to solve the problem of php database connection error

Recommended: "PHP Video Tutorial"

PHP Connection Database Error

Reason: PHP7.0 abolished the mysql_connect() function

Replacement function:

mysqli_connect();
Copy after login

Example:

<?PHP
    $conn=mysqli_connect("localhost","root","root");
    if($conn){
        echo"ok";
    }else{
        echo"error";    
    }
?>
Copy after login

The above is the detailed content of How to solve the problem of php database connection error. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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