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.
I just had this issue on a
ubuntu16.04
,php7.1
install withCodeigniter 3
.Solution was simple (if hard to find!)
I realised that the
mysql*.ini
files where missing from theetc/php/7.1/mods-available
directory. Not sure how it happened, but that worked for me.If you use 7.2, simply type
sudo apt-get install php7.2-mysql
I suggest you do the following:
change:
to:
in
database.php
file.It is not a bug in your application, it is just a missing driver, so, you have couple of options...
Go to your php init and uncomment the following:
If not, try installing it at your server, it varies depending on your distribution.
Try installing
php5-mysqlnd
If you cannot do it by hosting restrictions then just move to mysql driver (wont need to change other configurations or queries in CodeIgniter or anything else...)
like this (at your config file)
1、apt-get install (yum, compile install whatever) php5-mysqlnd extension.
2、if not work, make sure mysqli is loaded
if is loaded, you can see:
3、if not loaded use php --ini to find config file
4、if not config extension, config like this and remember restart your web server
If your webserver is running with a lower version of MySQL, then you will get this error as MySQLi is not supported in MySQL < 4.1.3
It is highly recommended to go with MySQLi instead of going back to MySQL extension.
More info on php.net
For me this was a missing line in php.ini that solved it, as I copied another php.ini file to my XAMPP installation. Worth checking if the line: "
extension=php_mysqli.dll
" exist (if running Windows, but this isn't applicable for OP, as it's a Linux system), or if the "extension_dir
" exists and is correct.