问题
i get an error when trying to connect to my database with mysqli on php 7.0 and php 7.1
PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /home/mywebsite/public_html/connection.php:7
$conn = mysqli_connect($DBhost,$DBuser,$DBpass,$DBname);
回答1:
First check, if mysqli is enabled:
phpinfo()
The mysqli PHP extension is not installed on your server. Contact to your server administrator.
OR
- If you host the server yourself, in the php.ini file remove the semicolon in front of the extension extension=php_mysqli.dll.
Hope, this helps you
回答2:
I would recommend using PHP PDO for database connection. Its got better performance and I think the code looks better.
But to speak on your error, it looks like php doesnt have a reference to mysqli library. Did you explicitly install the php-mysql package? Its also possible that the environment variable path is not pointing to the right location on the filesystem.
回答3:
Your php not instaled mysql connector , for install linux :
sudo install php-mysqli
Happens when php extensions are not being used by default. In your php.ini file, change
;extension=php_mysql.dll to extension=php_mysql.dll.
回答4:
The mysqli PHP extension
is not installed on your new server.
Contact to your server administrator.
If you host the server yourself, in the php.ini
file remove the semicolon in front of the extension extension=php_mysqli.dll
来源:https://stackoverflow.com/questions/42372552/mysqli-error-when-connecting-to-the-database