Home >Backend Development >PHP Problem >How to solve the problem of php database connection error

How to solve the problem of php database connection error

藏色散人
藏色散人Original
2020-08-21 09:29:123592browse

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();

Example:

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

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!

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