Home  >  Article  >  Backend Development  >  Why can't php connect to the database?

Why can't php connect to the database?

王林
王林Original
2019-09-29 17:47:569198browse

Why can't php connect to the database?

Solution to the problem that PHP cannot connect to the database

Solution process:

1 , First open the browser console to see if it is a browser problem.

2. Check the apache error log

Found the problem in /var/log/apache2/error.log.1:

Uncaught Error: Class 'mysqli' not found

3. Locking problem

The database extension is not enabled in the php.ini file.

3.1. Open /ect/php/7.2/apache2/php.ini

3.2. Find ;extension=mysqli and remove the previous comment

4 , Restart the apache server

After restarting the server, re-run the program.

Recommended tutorial: PHP video tutorial

The above is the detailed content of Why can't php connect to the database?. 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
Previous article:Why is php so efficient?Next article:Why is php so efficient?