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!