Codeigniter: fatal error call to undefined functio

2019-01-17 22:34发布

I just changed my server and experience these errors below:

Fatal error: Call to undefined function mysqli_init() in /home/blacktwitter/public_html/system/database/drivers/mysqli/mysqli_driver.php on line 126
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/blacktwitter/public_html/system/database/drivers/mysqli/mysqli_driver.php:126)

Filename: core/Common.php

Line Number: 564

Backtrace:

A PHP Error was encountered

Severity: Error

Message: Call to undefined function mysqli_init()

Filename: mysqli/mysqli_driver.php

Line Number: 126

Backtrace:

Website is in Codeigniter. It works on one server very well and on the local machine too. But when I upload that website at the new server I have that errors. Of course I changed important parameters like database connection, base_url() etc.

I was suspicious about database, but I have created a new database and user etc. and changed connection info.

Why does this happen? It will be helpful to know if it is a bug at the server or at the website. Also when I create some index.html with some test code everything is fine.

11条回答
劳资没心,怎么记你
2楼-- · 2019-01-17 23:00

I tried, comment out below line in /etc/php/cli/php.ini file.

extension=php_mysqli.dll

I am using Ubuntu 16.04 on AWS-EC2 instances and PHP 7.0. This solved my problem.

查看更多
放荡不羁爱自由
3楼-- · 2019-01-17 23:01

In Linux, you can install MySQL driver extension.

sudo apt-get install php-mysql

In Windows with XAMPP, the driver has already saved in ext directory, but you need to enable it in php.ini. You need to uncomment this line:

extension=php_mysqli.dll

You also need to check the extension directory location in php.ini. I use absolute path (not relative path) declaration to make it works.

extension_dir="your\absolute\path\to\xampp\php\ext"

For example,

extension_dir="C:\xampp\php\ext"
查看更多
一纸荒年 Trace。
4楼-- · 2019-01-17 23:02

This is actually not a CodeIgniter issue but PHP installation issue.

I have installed PHP5.6 in my Linux server and is having a hard time following the googled solutions of using the ff command in order to install the missing mysqli_extension in PHP.

What I tried is but is returning the warning message: Unable to locate package php5-mysqli

sudo apt-get install php5-mysqli

However, my php version is 5.6 so I tried

sudo apt-get install php5.6-mysqli

Then it works.

查看更多
我命由我不由天
5楼-- · 2019-01-17 23:02

Open the folder where you have installed PHP, Edit php.ini file
uncomment this line: extension=php_mysqli.dll

查看更多
霸刀☆藐视天下
6楼-- · 2019-01-17 23:05

Use this:

sudo apt-get install php7.*-mysqli

or

sudo phpenmod mysqli
sudo service apache2 restart
查看更多
登录 后发表回答