简体   繁体   中英

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM