mysqli error when connecting to the database [duplicate]

我们两清 提交于 2019-12-25 06:07:25

问题


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:


  1. First check, if mysqli is enabled: phpinfo()

  2. The mysqli PHP extension is not installed on your server. Contact to your server administrator.

OR

  1. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!