Gravity123
Gravity123

Reputation: 1130

Ubuntu PHP Fatal error: Call to undefined function mysqli_connect() in.. when calling PHP script

I run Ubuntu desktop 14.04 LTS (Trusty Tahr), and I am trying to setup Apache 2, MySQL server and PHP, but I keep gettin the following error:

PHP Fatal error: Call to undefined function mysqli_connect() in..

What I have done is these changes in the correct php.ini:

uncomment:

extension=msqli.so

set path aquired from phpinfo():

extension_dir = "./usr/lib/php5/20121212+lfs"

Why is the mysqli function to connect to the database still undefined?

Upvotes: 5

Views: 30531

Answers (2)

Andrew
Andrew

Reputation: 20061

running updates is usually recommended

sudo apt-get update

then install needed version

sudo apt-get install php5-mysql
sudo apt-get install php7.0-mysql
sudo apt-get install php7.1-mysql
sudo apt-get install php7.2-mysql

restart apache

sudo service apache2 restart

Upvotes: 8

syyu
syyu

Reputation: 407

In my case php5-mysql was missing from my Ubuntu server. After installing the package it is working fine with mysqli adapter.

sudo apt-get install php5-mysql

It resolved my CodeIgniter 3.0 mysqli connection valid.

Upvotes: 5

Related Questions