1

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);
Dharman
  • 30,962
  • 25
  • 85
  • 135
noynac
  • 25
  • 8
  • Check this out : http://stackoverflow.com/questions/35424982/how-to-enable-mysqli-extension-in-php-7 – Fredster Feb 21 '17 at 16:20

4 Answers4

3
  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

Owais
  • 854
  • 2
  • 13
  • 32
1

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.

victor
  • 802
  • 7
  • 12
  • PHP Fatal error: Uncaught Error: Class 'PDO' not found, (i think im just gonna switch host) – noynac Feb 22 '17 at 03:35
  • Well, you gotta install the PDO class. http://stackoverflow.com/questions/13375061/installing-pdo-driver-on-mysql-linux-server – victor Feb 28 '17 at 14:20
0

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.

0

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

Sachin PATIL
  • 745
  • 1
  • 9
  • 16