PHPMYADMIN: mbstring extension is missing [duplicate] - php

Whenever I try to enter my phpMyAdmin, it gives me this error:
The mbstring extension is missing. Please check your PHP configuration.
I've looked all over the Internet for a fix, but all I've found is errors similar to mine, but not the same, or the exact same but there was no fix given.
I am also using Windows.

In Centos I have installed a php extension.
I did this with:
yum install php-mbstring

Before sometime I also had the same problem. I have tried replacing the .dll file but no result. After some debugging I found the solution.
I had this in my php.ini file:
extension_dir = "ext"
And I'm getting mbstring extension missing error. So I tried putting the full path for the extension directory and it works for me. like:
extension_dir = "C:\php\ext"
Hope this will help.
Cheers,

check your php.ini file in the root directory of your php installation. In the extensions part of the configuration you should find:
;extension=php_mbstring.dll
remove the leading ';' to uncomment and enable the extension so it looks like this:
extension=php_mbstring.dll
restart your apache and it should work.
Edit: I just read that you are already using a webhost. Does your webhost have a interface where you can set php variables etc? Or a .ini file you can edit?
If not you may are forced to talk to the webhost and ask them to enable that particular extension.

My case was like this
Strangely, I noticed that the php.ini file that WAMP was using wasn't
the one in the php directory, but rather was referencing a php.ini
file in the bin directory... I copied my php.ini file to
wamp\bin\apache\apache2.4.17\bin directory, restarted the wamp
services and PHPMyadmin was off and running...
Thanks I solved the problem

In Ubuntu Server I have installed a php extension.
I did this with:
sudo apt-get install php-mbstring

Another reason for this problem is Php version. When I changed the running PHP version to 7.0.0, problem has gone.

Ubuntu 15.10
1) sudo nano /etc/php/7.0/apache2/php.ini
uncommited extension=php_mbstring.dll
2) sudo apt-get install php7.0-mbstring
3) restart apache2

install mbstring and restart your apache:
sudo apt-get install php-mbstring
sudo service apache restart
then remove ; from your php.ini file:
;extension=php_mbstring.dll
to
extension=php_mbstring.dll
If it still doesn't work..remove your php setup, without removing the databases from your phpmyadmin. Reinstall it.
NB: * if you want to remove all, all mention the one you need to.
sudo apt-get remove php*
Then install the php and modules of the php version that you need. here, php 7.1:
sudo apt-get install php7.1 php7.1-cli php7.1-common libapache2-mod-php7.1 php7.1-mysql php7.1-fpm php7.1-curl php7.1-gd php7.1-bz2 php7.1-mcrypt php7.1-json php7.1-tidy php7.1-mbstring php-redis php-memcached
restart your apache and check the php version.
sudo service apache restart
php -v
when all this is done, execute the following command to enable mbstring forcefully and restart your apache.
sudo phpenmod mbstring
sudo service apache restart
Hope it helps.
It did to me :)

I've solved my problem by this way:
Edit the php.ini file:
change extension_dir = "ext" into extension_dir = "D:\php\ext" (please write ur own full path for the extension directory)
change ;extension=php_mbstring.dll into extension=php_mbstring.dll (delete the ";")
Then just save your php.ini file and copy it to ur Windows directory。(“C:\Windows“)
restart the apache server。
The above is my solution,Hope it will work for u.

Using xampp, this will work (php7 has been extracted to the xampp\php directory):
Make the following changes in the php.ini:
uncommend (remove the ;)
;extension=php_mbstring.dll
uncommend (remove the ;)
;extension=php_mysqli.dll
set the path to the extention Directory
extension_dir = "ext"
to the full path, for example:
extension_dir = "C:\xammp\php\ext"
Additional, change the xampp-settings in the httpd-xampp.conf:
change
LoadFile "C:/xampp/php/php5ts.dll"
to
LoadFile "C:/xampp/php/php7ts.dll"
change
LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"
to
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
change all appearance (3 times) of
IfModule php5_module
to
IfModule php7_module
That's it.

I had this problem in the past with MAMP on a Windows machine.
Open MAMP start page and go to your current configuration of PHP (phpinfo).
Check the Configuration File (php.ini) PATH.
Mine was set to C:\Windows, where of course I had no PHP.ini file.
Either change the php.ini path to C:\MAMP\conf\php5.6.8 (or your php version conf path) or just copy php.ini to c:\windows.

after installing WAMP 3 with Apache 2.4.17 and php5.6.17 I tried to look at php.ini from wampserver (green icon in tray).
It wasn't finding it.
I copied php.ini from the php.5.6.15 directory to the apache2.4.17\bin\ directory
and phpmyadmin worked fine without missing mbstring

Solved it.
I tried all of the solutions above but it still did not work. I'm currently using WAMP to launch the mysql server. When I tried to open the "php.ini" file with the WAMP panel, it said that it did not exist and asked me to create a new "php.ini" in the location, "C:\wamp\bin\apache\apache2.4.17\bin". Once I created this new "php.ini" file, I located the existing "php.ini" file which was in the path "C:\wamp\bin\php\php5.6.15", and cloned it. I then pasted the clone in the previous path where it had asked me to create the "php.ini" file.
Hope this helped.

I just installed WAMP 3 on Windows 10 and had this issue.
I had to go to C:\wamp64\bin\php\php7.0.0\ and copy the php.ini file to C:\wamp64\bin\apache\apache2.4.17\bin\
Then I restarted WAMP, and was finally able to access my phpMyAdmin file.
Note: this is probably not the correct way to do this because now there are 2 php.ini files. There is probably a setting in an Apache file that points to the php.ini file, but I haven't seen that yet. I will update this if I find it.

Strangely, I noticed that the php.ini file that WAMP was using wasn't the one in the php directory, but rather was referencing a php.ini file in the bin directory... I copied my php.ini file to wamp\bin\apache\apache2.4.17\bin directory, restarted the wamp services and PHPMyadmin was off and running...

In newer versions of PHP, "extension_dir" is not initially enabled.

In php's directory try change extension of configuration file (php.ini-development - default value of this file). I changed it to php.ini and phpmyadmin has worked.

The program can't start because php_mbstring.dll is missing from your computer. Try to fix it.
i use appserver to localhost and my server: C:/AppServ/www/dvd2/variables.php
Mozilla/5.0 (Windows NT 6.1; rv:33.0) Gecko/20100101 Firefox/33.0
Apache/2.2.8 (Win32) PHP/5.2.6

To solve this problem on Linux, you need to recompile your PHP with the --enable-mbstring flag.

You might get this error message if you've just installed the phpmyadmin package but haven't restarted apache yet; try restarting apache.

Please uncomment the following lines at php.ini
;extension=php_mbstring.dll
;extension=php_exif.dll ; Must be after mbstring as it depends on it
;extension=php_mysql.dll
;extension=php_mysqli.dll
This will help to solve.

The version of phpadmin you have installed is not compatible with the version of apache. Install the compatible version and you should be fine

I recently updated from PHP 5.4.44 to PHP 5.6.12 on my Windows 8.1 OS and got this phpMyAdmin missing mbstring error message.
After trying the above suggestions, none of which worked for me, I discovered version 5.4.44 placed the DLL extensions in the PHP root directory whereas version 5.6.12 placed them in the PHP\ext subdirectory.
All very fine except unfortunately someone forgot to change the php.ini accordingly. So two possible solutions:
Copy the DLL extensions from the ext sub-directory into the PHP root directory, or
Edit the php.ini file to call all the DLL extensions from the ext sub-directory.
I chose the easier first and phpMyAdmin now works fine.

Depending on you OS, you might need to install additional packets, e.g. php5-mbstring in SLES Linux.

I check phpinfo() and look for this line:
Configuration File (php.ini) Path C:\Windows
And I copy php.ini from C:\xampp\php to the folder and it works for me.

I had the same problem, the above solutions are not worked for me.
What I did is uninstalled the wamp and logout the Skype and re-installed wamp.
Then It got worked. I think the port used by wamp and Skype is same.
Hope this input will help.
Cheers :)

my solution : Copy a shortcut from your php.ini from your php-directory to the apache-dir. This way you refere too 1 file on the correct place. This solved (at least in my case) the problem.

just copy the php.ini file from C:\wamp\bin\apache\apache2.4.17\bin to C:\wamp\bin\apache\apache2.4.17\bin and then again restart apache server..
it will work fine.

My solution:
I had wamp x32 installed before, needed to remove and then installed the x64, receiving the same message "The mbstring extension is missing. Please check your PHP configuration.".
On php.ini, all references to wamp, such as extension_dir = were pointing to "C:/Program Files/Wamp/...". Check all paths, the correct for me is "C:/Wamp64/". Restart services and it's all right now.

The installation process adds the phpMyAdmin Apache configuration file into the /etc/apache2/conf-enabled/ directory, where it is read automatically. The only thing you need to do is explicitly enable the mbstring PHP extension, Because sometimes you forgot to enable the mbstring mode so simply type the below command to enabled the mbstring mode...
sudo phpenmod mbstring
Afterward, restart Apache for your changes to be recognized:
sudo systemctl restart apache2

Related

Can't connect to Database through PHP built in server [duplicate]

I am doing a tutorial and am getting this error:
Fatal error: Class 'MySQLi' not found (LONG URL) on line 8
The code on line 8 is:
$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name);
I saw online someone said to see if it was turned on in my phpinfo(), but there wasn't anything listed in there under for "mysqli".
Also, I am running PHP version 5.2.5
Sounds like you just need to install MySQLi.
If you think you've done that and still have a problem, please post your operating system and anything else that might help diagnose it further.
You can check if the mysqli libraries are present by executing this code:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'We don\'t have mysqli!!!';
} else {
echo 'Phew we have it!';
}
If you are on Ubuntu, run:
sudo apt-get install php-mysqlnd
And don't forget to restart the php service after this (Apache or php-fpm depends on the setup).
If you're calling "new mysqli(..)" from within a class that is namespaced, you might see a similar error Fatal error: Class 'foo\bar\mysqli' not found in. The way to fix this is to explicitly set it to the root namespace with a preceding backslash like so:
<?php
$mysqli = new \MySQLi($db_server, $db_user, $db_pass, $db_name);
In addition to uncommenting the php_mysqli.dll extension in php.ini, also uncomment the extension_dir directive in php.ini and specify your location:
extension_dir = "C:\software\php\dist\ext"
This made it work for me.
If you are on Docker...
Inside php-container RUN:
#docker-php-ext-install mysqli
#apachectl restart
My OS is Ubuntu. I solved this problem by using:
sudo apt-get install php5-mysql
How to Enable mysqli in php.ini
Edit/uncomment by removing ';'(colon) the following config in php.ini:
1st (uncomment and add config):
include_path = "C:\php\includes"
2nd (uncomment):
extension_dir = "ext"
3rd (uncomment and edit config):
extension=C:/PHP/ext/php_mysql.dll
extension=C:/PHP/ext/php_mysqli.dll
Restart the IIS server
Make sure that mysql is running on the system.
How to load php.ini file
Rename any one of the file php.ini-production/php.ini-development to php.ini from C:\PHP(note now the extention will be ini i.e "php.ini").
After renaming to php.ini file restart server
See the changes in http://localhost/phpinfo.php
For anyone using docker, I ran into this issue, and resolved it by using my own Dockerfile instead of the php:fpm image:
FROM php:fpm
RUN docker-php-ext-install mysqli
Seems like problem with your installation.
Have you installed MySQLi?
Have you activated it in php.ini?
Restarted Apache and/or PHP-FPM?
http://www.php.net/manual/en/mysqli.installation.php
Open your PHP folder.
Find php.ini-development and open it.
Find ;extension=mysqli
delete the ; symbol
save file and change the file extension from php.ini-development to php.ini
Restart the server and test the code:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'We don\'t have mysqli!!!';
} else {
echo 'mysqli is installed';
}
if it not working, change both extension_dir in php.ini from "ext" to "c:\php\ext"
and extension=mysqli to extension=php_mysqli.dll then test again
Remember to reset the server every time you test
The PHP zip includes most of the commonly used extensions (*.dll on windows such as php_mysqli.dll) under the \ext directory, however they are not enabled by default. You might be getting this Fatal Error when trying to use MySQLi:
( ! ) Fatal error: Uncaught Error: Class 'mysqli' not found in C:\myProject\ class.Database.php on line 24
To enable extensions, open php.ini (you might need to first copy php.ini-development as php.ini), and un-comment (or add) these two lines:
extension_dir = "ext"
And any particular extensions you are getting Fatal Errors for, i.e. for mysqli:
extension=mysqli
On a fresh install of PHP, remove ; before extension_dir in php.ini.
I thought I might help anybody with the same problem using Namesco servers.
I have been trying to fix this problem after moving a database from my local server on home pc to namesco. They would not assist they said it was a coding issue.
However, it was simple to fix from their CPANEl LINUX hosting
interface.
Click on php.
then click on php modules and from their list of preinstalled modules just click the box for mysqli.
Then click save. (No need to change code if it worked(s) on another server.)
Unfortunately, their support articles were a waste of time. After reading this I went to admin interface with a new determination.
Some distributions (such as Gentoo) support multiple installations of PHP, and you have to make sure you're using one with mysqli installed and enabled.
On Gentoo, I had installed a new PHP (with the mysqli USE flag enabled), but I needed to activate the new version of PHP (since the old one must have been missing mysqli):
# eselect php list apache2
[1] php5.3 *
[2] php5.5
# eselect php set apache2 2
You have to run `/etc/init.d/apache2 restart' for the changes to take effect
# /etc/init.d/apache2 restart
I checked all above and it didn't work for me,
There are some steps I found.
I used PHP Version 5.5.9-1ubuntu4.17 on Ubuntu 14.04
First check the folder
#ls /etc/php5/mods-available/
json.ini mcrypt.ini mysqli.ini mysql.ini mysqlnd.ini opcache.ini pdo.ini pdo_mysql.ini readline.ini xcache.ini
If it did not contain mysqli.ini, read other answer for installing it,
Open php.ini find extension_dir
In my case , I must set extension_dir = /usr/lib/php5/20121212
And restart apache2 : /ect/init.d/apache2 restart
on ubuntu:
sudo apt-get install php-mysql
sudo service apache2 restart
on Debian 10
apt install php-mysql
/etc/init.d/apache2 restart
I found a solution for this problem after a long analysing procedure.
After properly testing my php installation with the command line features I found out that the php is working well and could work with the mysql database. Btw. you can run code-files with php code with the command php -f filename.php
So I realized, it must something be wrong with the Apache.
I made a file with just the phpinfo() function inside.
Here I saw, that in the line
Loaded Configuration File
my config file was not loaded, instead there was mentioned (none).
Finally I found within the Apache configuration the entry
<IfModule php5_module>
PHPINIDir "C:/xampp/php"
</IfModule>
But I've installed the PHP 7 and so the Apache could not load the php.ini file because there was no entry for that.
I added
<IfModule php7_module>
PHPINIDir "C:/xampp/php"
</IfModule>
and after restart Apache all works well.
These code blocks above I found in my httpd-xampp.conf file. May it is somewhere else at your configuration.
In the same file I had changed before the settings for the php 7 as replacement for the php 5 version.
#
# PHP-Module setup
#
#LoadFile "C:/xampp/php/php5ts.dll"
#LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"
LoadFile "C:/xampp/php/php7ts.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
As you can see I have the xampp package installed but this problem was just on the Apache side.
install
phpXX-extension by PHP.
In my FreeBSD's case:
pkg install php74-extensions
I'm using xampp and my problem was fixed once i rename:
extension_dir = "ext"
to
extension_dir = "C:\xampp\php\ext"
PS: Don't forget to restart apache after making this change!
In php.ini :
extension_dir ="c:/wamp64/bin/php/php7.4.9/ext/"
Make sure the PHP version is correct.
All you have to do is go to the php.ini file and on line 926 (depending on version) delete #. It should look like this:
;extension=ldap
;extension=mbstring
;extension=exif
extension=mysqli
;extension=oci8_12c
;extension=odbc
Save the file and open console (cmd) as administrator. Go to the path Apache24 / bin and enter httpd -k restart. This command will restart your server. After that, refresh the page and everything should work.
When I tried my PHP web app it was giving me the same error.
By googling I found out the MySQL plugin for the PHP server was missing with my installation. I am using Ubuntu, so when I tried MySQL plugin for PHP I found out 2 are there,
php-mysql and php<version>-mysql
I issued command - php --version in my terminal, I was having php7.4,
again I issued apt install php7.4-mysql
It worked.
This issue can be also caused by the .htaccess file misconfiguration.

Class "mysqli" not found in ....db.driver.inc.php [duplicate]

I am doing a tutorial and am getting this error:
Fatal error: Class 'MySQLi' not found (LONG URL) on line 8
The code on line 8 is:
$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name);
I saw online someone said to see if it was turned on in my phpinfo(), but there wasn't anything listed in there under for "mysqli".
Also, I am running PHP version 5.2.5
Sounds like you just need to install MySQLi.
If you think you've done that and still have a problem, please post your operating system and anything else that might help diagnose it further.
You can check if the mysqli libraries are present by executing this code:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'We don\'t have mysqli!!!';
} else {
echo 'Phew we have it!';
}
If you are on Ubuntu, run:
sudo apt-get install php-mysqlnd
And don't forget to restart the php service after this (Apache or php-fpm depends on the setup).
If you're calling "new mysqli(..)" from within a class that is namespaced, you might see a similar error Fatal error: Class 'foo\bar\mysqli' not found in. The way to fix this is to explicitly set it to the root namespace with a preceding backslash like so:
<?php
$mysqli = new \MySQLi($db_server, $db_user, $db_pass, $db_name);
In addition to uncommenting the php_mysqli.dll extension in php.ini, also uncomment the extension_dir directive in php.ini and specify your location:
extension_dir = "C:\software\php\dist\ext"
This made it work for me.
If you are on Docker...
Inside php-container RUN:
#docker-php-ext-install mysqli
#apachectl restart
My OS is Ubuntu. I solved this problem by using:
sudo apt-get install php5-mysql
How to Enable mysqli in php.ini
Edit/uncomment by removing ';'(colon) the following config in php.ini:
1st (uncomment and add config):
include_path = "C:\php\includes"
2nd (uncomment):
extension_dir = "ext"
3rd (uncomment and edit config):
extension=C:/PHP/ext/php_mysql.dll
extension=C:/PHP/ext/php_mysqli.dll
Restart the IIS server
Make sure that mysql is running on the system.
How to load php.ini file
Rename any one of the file php.ini-production/php.ini-development to php.ini from C:\PHP(note now the extention will be ini i.e "php.ini").
After renaming to php.ini file restart server
See the changes in http://localhost/phpinfo.php
For anyone using docker, I ran into this issue, and resolved it by using my own Dockerfile instead of the php:fpm image:
FROM php:fpm
RUN docker-php-ext-install mysqli
Seems like problem with your installation.
Have you installed MySQLi?
Have you activated it in php.ini?
Restarted Apache and/or PHP-FPM?
http://www.php.net/manual/en/mysqli.installation.php
Open your PHP folder.
Find php.ini-development and open it.
Find ;extension=mysqli
delete the ; symbol
save file and change the file extension from php.ini-development to php.ini
Restart the server and test the code:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'We don\'t have mysqli!!!';
} else {
echo 'mysqli is installed';
}
if it not working, change both extension_dir in php.ini from "ext" to "c:\php\ext"
and extension=mysqli to extension=php_mysqli.dll then test again
Remember to reset the server every time you test
The PHP zip includes most of the commonly used extensions (*.dll on windows such as php_mysqli.dll) under the \ext directory, however they are not enabled by default. You might be getting this Fatal Error when trying to use MySQLi:
( ! ) Fatal error: Uncaught Error: Class 'mysqli' not found in C:\myProject\ class.Database.php on line 24
To enable extensions, open php.ini (you might need to first copy php.ini-development as php.ini), and un-comment (or add) these two lines:
extension_dir = "ext"
And any particular extensions you are getting Fatal Errors for, i.e. for mysqli:
extension=mysqli
On a fresh install of PHP, remove ; before extension_dir in php.ini.
I thought I might help anybody with the same problem using Namesco servers.
I have been trying to fix this problem after moving a database from my local server on home pc to namesco. They would not assist they said it was a coding issue.
However, it was simple to fix from their CPANEl LINUX hosting
interface.
Click on php.
then click on php modules and from their list of preinstalled modules just click the box for mysqli.
Then click save. (No need to change code if it worked(s) on another server.)
Unfortunately, their support articles were a waste of time. After reading this I went to admin interface with a new determination.
Some distributions (such as Gentoo) support multiple installations of PHP, and you have to make sure you're using one with mysqli installed and enabled.
On Gentoo, I had installed a new PHP (with the mysqli USE flag enabled), but I needed to activate the new version of PHP (since the old one must have been missing mysqli):
# eselect php list apache2
[1] php5.3 *
[2] php5.5
# eselect php set apache2 2
You have to run `/etc/init.d/apache2 restart' for the changes to take effect
# /etc/init.d/apache2 restart
I checked all above and it didn't work for me,
There are some steps I found.
I used PHP Version 5.5.9-1ubuntu4.17 on Ubuntu 14.04
First check the folder
#ls /etc/php5/mods-available/
json.ini mcrypt.ini mysqli.ini mysql.ini mysqlnd.ini opcache.ini pdo.ini pdo_mysql.ini readline.ini xcache.ini
If it did not contain mysqli.ini, read other answer for installing it,
Open php.ini find extension_dir
In my case , I must set extension_dir = /usr/lib/php5/20121212
And restart apache2 : /ect/init.d/apache2 restart
on ubuntu:
sudo apt-get install php-mysql
sudo service apache2 restart
on Debian 10
apt install php-mysql
/etc/init.d/apache2 restart
I found a solution for this problem after a long analysing procedure.
After properly testing my php installation with the command line features I found out that the php is working well and could work with the mysql database. Btw. you can run code-files with php code with the command php -f filename.php
So I realized, it must something be wrong with the Apache.
I made a file with just the phpinfo() function inside.
Here I saw, that in the line
Loaded Configuration File
my config file was not loaded, instead there was mentioned (none).
Finally I found within the Apache configuration the entry
<IfModule php5_module>
PHPINIDir "C:/xampp/php"
</IfModule>
But I've installed the PHP 7 and so the Apache could not load the php.ini file because there was no entry for that.
I added
<IfModule php7_module>
PHPINIDir "C:/xampp/php"
</IfModule>
and after restart Apache all works well.
These code blocks above I found in my httpd-xampp.conf file. May it is somewhere else at your configuration.
In the same file I had changed before the settings for the php 7 as replacement for the php 5 version.
#
# PHP-Module setup
#
#LoadFile "C:/xampp/php/php5ts.dll"
#LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"
LoadFile "C:/xampp/php/php7ts.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
As you can see I have the xampp package installed but this problem was just on the Apache side.
install
phpXX-extension by PHP.
In my FreeBSD's case:
pkg install php74-extensions
I'm using xampp and my problem was fixed once i rename:
extension_dir = "ext"
to
extension_dir = "C:\xampp\php\ext"
PS: Don't forget to restart apache after making this change!
In php.ini :
extension_dir ="c:/wamp64/bin/php/php7.4.9/ext/"
Make sure the PHP version is correct.
All you have to do is go to the php.ini file and on line 926 (depending on version) delete #. It should look like this:
;extension=ldap
;extension=mbstring
;extension=exif
extension=mysqli
;extension=oci8_12c
;extension=odbc
Save the file and open console (cmd) as administrator. Go to the path Apache24 / bin and enter httpd -k restart. This command will restart your server. After that, refresh the page and everything should work.
When I tried my PHP web app it was giving me the same error.
By googling I found out the MySQL plugin for the PHP server was missing with my installation. I am using Ubuntu, so when I tried MySQL plugin for PHP I found out 2 are there,
php-mysql and php<version>-mysql
I issued command - php --version in my terminal, I was having php7.4,
again I issued apt install php7.4-mysql
It worked.
This issue can be also caused by the .htaccess file misconfiguration.

PHP8 MySQLi class cannot be found [duplicate]

I am doing a tutorial and am getting this error:
Fatal error: Class 'MySQLi' not found (LONG URL) on line 8
The code on line 8 is:
$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name);
I saw online someone said to see if it was turned on in my phpinfo(), but there wasn't anything listed in there under for "mysqli".
Also, I am running PHP version 5.2.5
Sounds like you just need to install MySQLi.
If you think you've done that and still have a problem, please post your operating system and anything else that might help diagnose it further.
You can check if the mysqli libraries are present by executing this code:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'We don\'t have mysqli!!!';
} else {
echo 'Phew we have it!';
}
If you are on Ubuntu, run:
sudo apt-get install php-mysqlnd
And don't forget to restart the php service after this (Apache or php-fpm depends on the setup).
If you're calling "new mysqli(..)" from within a class that is namespaced, you might see a similar error Fatal error: Class 'foo\bar\mysqli' not found in. The way to fix this is to explicitly set it to the root namespace with a preceding backslash like so:
<?php
$mysqli = new \MySQLi($db_server, $db_user, $db_pass, $db_name);
In addition to uncommenting the php_mysqli.dll extension in php.ini, also uncomment the extension_dir directive in php.ini and specify your location:
extension_dir = "C:\software\php\dist\ext"
This made it work for me.
If you are on Docker...
Inside php-container RUN:
#docker-php-ext-install mysqli
#apachectl restart
My OS is Ubuntu. I solved this problem by using:
sudo apt-get install php5-mysql
How to Enable mysqli in php.ini
Edit/uncomment by removing ';'(colon) the following config in php.ini:
1st (uncomment and add config):
include_path = "C:\php\includes"
2nd (uncomment):
extension_dir = "ext"
3rd (uncomment and edit config):
extension=C:/PHP/ext/php_mysql.dll
extension=C:/PHP/ext/php_mysqli.dll
Restart the IIS server
Make sure that mysql is running on the system.
How to load php.ini file
Rename any one of the file php.ini-production/php.ini-development to php.ini from C:\PHP(note now the extention will be ini i.e "php.ini").
After renaming to php.ini file restart server
See the changes in http://localhost/phpinfo.php
For anyone using docker, I ran into this issue, and resolved it by using my own Dockerfile instead of the php:fpm image:
FROM php:fpm
RUN docker-php-ext-install mysqli
Seems like problem with your installation.
Have you installed MySQLi?
Have you activated it in php.ini?
Restarted Apache and/or PHP-FPM?
http://www.php.net/manual/en/mysqli.installation.php
Open your PHP folder.
Find php.ini-development and open it.
Find ;extension=mysqli
delete the ; symbol
save file and change the file extension from php.ini-development to php.ini
Restart the server and test the code:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'We don\'t have mysqli!!!';
} else {
echo 'mysqli is installed';
}
if it not working, change both extension_dir in php.ini from "ext" to "c:\php\ext"
and extension=mysqli to extension=php_mysqli.dll then test again
Remember to reset the server every time you test
The PHP zip includes most of the commonly used extensions (*.dll on windows such as php_mysqli.dll) under the \ext directory, however they are not enabled by default. You might be getting this Fatal Error when trying to use MySQLi:
( ! ) Fatal error: Uncaught Error: Class 'mysqli' not found in C:\myProject\ class.Database.php on line 24
To enable extensions, open php.ini (you might need to first copy php.ini-development as php.ini), and un-comment (or add) these two lines:
extension_dir = "ext"
And any particular extensions you are getting Fatal Errors for, i.e. for mysqli:
extension=mysqli
On a fresh install of PHP, remove ; before extension_dir in php.ini.
I thought I might help anybody with the same problem using Namesco servers.
I have been trying to fix this problem after moving a database from my local server on home pc to namesco. They would not assist they said it was a coding issue.
However, it was simple to fix from their CPANEl LINUX hosting
interface.
Click on php.
then click on php modules and from their list of preinstalled modules just click the box for mysqli.
Then click save. (No need to change code if it worked(s) on another server.)
Unfortunately, their support articles were a waste of time. After reading this I went to admin interface with a new determination.
Some distributions (such as Gentoo) support multiple installations of PHP, and you have to make sure you're using one with mysqli installed and enabled.
On Gentoo, I had installed a new PHP (with the mysqli USE flag enabled), but I needed to activate the new version of PHP (since the old one must have been missing mysqli):
# eselect php list apache2
[1] php5.3 *
[2] php5.5
# eselect php set apache2 2
You have to run `/etc/init.d/apache2 restart' for the changes to take effect
# /etc/init.d/apache2 restart
I checked all above and it didn't work for me,
There are some steps I found.
I used PHP Version 5.5.9-1ubuntu4.17 on Ubuntu 14.04
First check the folder
#ls /etc/php5/mods-available/
json.ini mcrypt.ini mysqli.ini mysql.ini mysqlnd.ini opcache.ini pdo.ini pdo_mysql.ini readline.ini xcache.ini
If it did not contain mysqli.ini, read other answer for installing it,
Open php.ini find extension_dir
In my case , I must set extension_dir = /usr/lib/php5/20121212
And restart apache2 : /ect/init.d/apache2 restart
on ubuntu:
sudo apt-get install php-mysql
sudo service apache2 restart
on Debian 10
apt install php-mysql
/etc/init.d/apache2 restart
I found a solution for this problem after a long analysing procedure.
After properly testing my php installation with the command line features I found out that the php is working well and could work with the mysql database. Btw. you can run code-files with php code with the command php -f filename.php
So I realized, it must something be wrong with the Apache.
I made a file with just the phpinfo() function inside.
Here I saw, that in the line
Loaded Configuration File
my config file was not loaded, instead there was mentioned (none).
Finally I found within the Apache configuration the entry
<IfModule php5_module>
PHPINIDir "C:/xampp/php"
</IfModule>
But I've installed the PHP 7 and so the Apache could not load the php.ini file because there was no entry for that.
I added
<IfModule php7_module>
PHPINIDir "C:/xampp/php"
</IfModule>
and after restart Apache all works well.
These code blocks above I found in my httpd-xampp.conf file. May it is somewhere else at your configuration.
In the same file I had changed before the settings for the php 7 as replacement for the php 5 version.
#
# PHP-Module setup
#
#LoadFile "C:/xampp/php/php5ts.dll"
#LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"
LoadFile "C:/xampp/php/php7ts.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
As you can see I have the xampp package installed but this problem was just on the Apache side.
install
phpXX-extension by PHP.
In my FreeBSD's case:
pkg install php74-extensions
I'm using xampp and my problem was fixed once i rename:
extension_dir = "ext"
to
extension_dir = "C:\xampp\php\ext"
PS: Don't forget to restart apache after making this change!
In php.ini :
extension_dir ="c:/wamp64/bin/php/php7.4.9/ext/"
Make sure the PHP version is correct.
All you have to do is go to the php.ini file and on line 926 (depending on version) delete #. It should look like this:
;extension=ldap
;extension=mbstring
;extension=exif
extension=mysqli
;extension=oci8_12c
;extension=odbc
Save the file and open console (cmd) as administrator. Go to the path Apache24 / bin and enter httpd -k restart. This command will restart your server. After that, refresh the page and everything should work.
When I tried my PHP web app it was giving me the same error.
By googling I found out the MySQL plugin for the PHP server was missing with my installation. I am using Ubuntu, so when I tried MySQL plugin for PHP I found out 2 are there,
php-mysql and php<version>-mysql
I issued command - php --version in my terminal, I was having php7.4,
again I issued apt install php7.4-mysql
It worked.
This issue can be also caused by the .htaccess file misconfiguration.

A white page appears when you press on 'Click here' on the bWAPP/install.php path [duplicate]

I am doing a tutorial and am getting this error:
Fatal error: Class 'MySQLi' not found (LONG URL) on line 8
The code on line 8 is:
$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name);
I saw online someone said to see if it was turned on in my phpinfo(), but there wasn't anything listed in there under for "mysqli".
Also, I am running PHP version 5.2.5
Sounds like you just need to install MySQLi.
If you think you've done that and still have a problem, please post your operating system and anything else that might help diagnose it further.
You can check if the mysqli libraries are present by executing this code:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'We don\'t have mysqli!!!';
} else {
echo 'Phew we have it!';
}
If you are on Ubuntu, run:
sudo apt-get install php-mysqlnd
And don't forget to restart the php service after this (Apache or php-fpm depends on the setup).
If you're calling "new mysqli(..)" from within a class that is namespaced, you might see a similar error Fatal error: Class 'foo\bar\mysqli' not found in. The way to fix this is to explicitly set it to the root namespace with a preceding backslash like so:
<?php
$mysqli = new \MySQLi($db_server, $db_user, $db_pass, $db_name);
In addition to uncommenting the php_mysqli.dll extension in php.ini, also uncomment the extension_dir directive in php.ini and specify your location:
extension_dir = "C:\software\php\dist\ext"
This made it work for me.
If you are on Docker...
Inside php-container RUN:
#docker-php-ext-install mysqli
#apachectl restart
My OS is Ubuntu. I solved this problem by using:
sudo apt-get install php5-mysql
How to Enable mysqli in php.ini
Edit/uncomment by removing ';'(colon) the following config in php.ini:
1st (uncomment and add config):
include_path = "C:\php\includes"
2nd (uncomment):
extension_dir = "ext"
3rd (uncomment and edit config):
extension=C:/PHP/ext/php_mysql.dll
extension=C:/PHP/ext/php_mysqli.dll
Restart the IIS server
Make sure that mysql is running on the system.
How to load php.ini file
Rename any one of the file php.ini-production/php.ini-development to php.ini from C:\PHP(note now the extention will be ini i.e "php.ini").
After renaming to php.ini file restart server
See the changes in http://localhost/phpinfo.php
For anyone using docker, I ran into this issue, and resolved it by using my own Dockerfile instead of the php:fpm image:
FROM php:fpm
RUN docker-php-ext-install mysqli
Seems like problem with your installation.
Have you installed MySQLi?
Have you activated it in php.ini?
Restarted Apache and/or PHP-FPM?
http://www.php.net/manual/en/mysqli.installation.php
Open your PHP folder.
Find php.ini-development and open it.
Find ;extension=mysqli
delete the ; symbol
save file and change the file extension from php.ini-development to php.ini
Restart the server and test the code:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'We don\'t have mysqli!!!';
} else {
echo 'mysqli is installed';
}
if it not working, change both extension_dir in php.ini from "ext" to "c:\php\ext"
and extension=mysqli to extension=php_mysqli.dll then test again
Remember to reset the server every time you test
The PHP zip includes most of the commonly used extensions (*.dll on windows such as php_mysqli.dll) under the \ext directory, however they are not enabled by default. You might be getting this Fatal Error when trying to use MySQLi:
( ! ) Fatal error: Uncaught Error: Class 'mysqli' not found in C:\myProject\ class.Database.php on line 24
To enable extensions, open php.ini (you might need to first copy php.ini-development as php.ini), and un-comment (or add) these two lines:
extension_dir = "ext"
And any particular extensions you are getting Fatal Errors for, i.e. for mysqli:
extension=mysqli
On a fresh install of PHP, remove ; before extension_dir in php.ini.
I thought I might help anybody with the same problem using Namesco servers.
I have been trying to fix this problem after moving a database from my local server on home pc to namesco. They would not assist they said it was a coding issue.
However, it was simple to fix from their CPANEl LINUX hosting
interface.
Click on php.
then click on php modules and from their list of preinstalled modules just click the box for mysqli.
Then click save. (No need to change code if it worked(s) on another server.)
Unfortunately, their support articles were a waste of time. After reading this I went to admin interface with a new determination.
Some distributions (such as Gentoo) support multiple installations of PHP, and you have to make sure you're using one with mysqli installed and enabled.
On Gentoo, I had installed a new PHP (with the mysqli USE flag enabled), but I needed to activate the new version of PHP (since the old one must have been missing mysqli):
# eselect php list apache2
[1] php5.3 *
[2] php5.5
# eselect php set apache2 2
You have to run `/etc/init.d/apache2 restart' for the changes to take effect
# /etc/init.d/apache2 restart
I checked all above and it didn't work for me,
There are some steps I found.
I used PHP Version 5.5.9-1ubuntu4.17 on Ubuntu 14.04
First check the folder
#ls /etc/php5/mods-available/
json.ini mcrypt.ini mysqli.ini mysql.ini mysqlnd.ini opcache.ini pdo.ini pdo_mysql.ini readline.ini xcache.ini
If it did not contain mysqli.ini, read other answer for installing it,
Open php.ini find extension_dir
In my case , I must set extension_dir = /usr/lib/php5/20121212
And restart apache2 : /ect/init.d/apache2 restart
on ubuntu:
sudo apt-get install php-mysql
sudo service apache2 restart
on Debian 10
apt install php-mysql
/etc/init.d/apache2 restart
I found a solution for this problem after a long analysing procedure.
After properly testing my php installation with the command line features I found out that the php is working well and could work with the mysql database. Btw. you can run code-files with php code with the command php -f filename.php
So I realized, it must something be wrong with the Apache.
I made a file with just the phpinfo() function inside.
Here I saw, that in the line
Loaded Configuration File
my config file was not loaded, instead there was mentioned (none).
Finally I found within the Apache configuration the entry
<IfModule php5_module>
PHPINIDir "C:/xampp/php"
</IfModule>
But I've installed the PHP 7 and so the Apache could not load the php.ini file because there was no entry for that.
I added
<IfModule php7_module>
PHPINIDir "C:/xampp/php"
</IfModule>
and after restart Apache all works well.
These code blocks above I found in my httpd-xampp.conf file. May it is somewhere else at your configuration.
In the same file I had changed before the settings for the php 7 as replacement for the php 5 version.
#
# PHP-Module setup
#
#LoadFile "C:/xampp/php/php5ts.dll"
#LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"
LoadFile "C:/xampp/php/php7ts.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
As you can see I have the xampp package installed but this problem was just on the Apache side.
install
phpXX-extension by PHP.
In my FreeBSD's case:
pkg install php74-extensions
I'm using xampp and my problem was fixed once i rename:
extension_dir = "ext"
to
extension_dir = "C:\xampp\php\ext"
PS: Don't forget to restart apache after making this change!
In php.ini :
extension_dir ="c:/wamp64/bin/php/php7.4.9/ext/"
Make sure the PHP version is correct.
All you have to do is go to the php.ini file and on line 926 (depending on version) delete #. It should look like this:
;extension=ldap
;extension=mbstring
;extension=exif
extension=mysqli
;extension=oci8_12c
;extension=odbc
Save the file and open console (cmd) as administrator. Go to the path Apache24 / bin and enter httpd -k restart. This command will restart your server. After that, refresh the page and everything should work.
When I tried my PHP web app it was giving me the same error.
By googling I found out the MySQL plugin for the PHP server was missing with my installation. I am using Ubuntu, so when I tried MySQL plugin for PHP I found out 2 are there,
php-mysql and php<version>-mysql
I issued command - php --version in my terminal, I was having php7.4,
again I issued apt install php7.4-mysql
It worked.
This issue can be also caused by the .htaccess file misconfiguration.

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

I have ubuntu 14.04 EC2 instance. I have installed php 7 on it. when I execute any php command like php --version or any other. I get following error
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_mysqli.dll' - /usr/lib/php/20151012/php_mysqli.dll: cannot open shared object file: No such file or directory in Unknown on line 0
I have tried following
enable php_mysqli.dll in php.ini
enable mysqli.so
enable php_mysqli.so
sudo apt-get install php-mysql
but nothing worked for me.
Any suggestion how I can solve this?
If you are on Linux, you shouldn't have DLL files but SO files.
So first, you have to remove / disable the php_mysqli.dll you added in php.ini.
In order to use mysqli, you should then :
install the package for Ubuntu : apt-get install php-mysql
check if it is already enabled (with phpinfo() for example)
if not enabled, enable the module - check in /etc/php/mods-available/ folder if there is a mysqli.ini, containing extension=mysqli.so, then check for CLI / FPM / Apache / other if there is the symbolic link pointing to this file (for example for CLI, in /etc/php/cli/conf.d/ : 20-mysqli.ini -> ../../mods-available/mysqli.ini)
restart php / apache / nginx depending what you are using
In my case, it happened because I uncommented the extension=php_mysqli.dll line in php.ini file for running some other package. After Googling around I found that you should not uncomment anything directly from php.ini instead you should install the required PHP extension and it will do the rest.
I have recently encountered this problem on ubuntu16.04, I finally resolve it by adding a semi-colon at each line like extension=php_*.dll,I think that is because LAMP on ubuntu is intelligent enough,it automatically opens all of the extensions for us. And on windows,we have to enable the extensions manually by remove the semi-colon at each line like ;extension=php_*.dll in php.ini.
Run Phpinfo()
Search for your php.ini path
search extension=php_mysqli.so
comment like this
;extension=php_mysqli.so
If you are on Linux and using php8.1,
try to commenting extension=pdo_mysql in directory /etc/php/8.1/cli/php.ini file if the extension is uncommenting
uncommenting extension=pdo_mysql in directory
/etc/php/8.1/apache2/php.ini file if the extension is commenting
this method work for me
I just had the same problem and realised they were two folders in my /etc/php/7.0, which were apache2 and cli. Turned out the extension line in cli/php.ini was uncommented with the dll file, not the one in apache2 directory. Commenting it just solved the problem.
I managed to solved it like this:
add libs to php.ini (etc/php/7.3/apache2; etc/php/7.3/cli folders)
extension=pdo_mysql.so
restart apache (sudo systemctl restart apache2)
comment libs in php.ini (etc/php/7.3/apache2; etc/php/7.3/cli folder)
extension=pdo_mysql.so
go etc/php/7.3/mod_available
comment extension (because it is already loaded), for example, etc/php/7.3/mod_available/pdo_mysql.ini
;extension=pdo_mysql.so
If you see mcrypt.so under /etc/php/7.2 or /etc/php/7.3 just delete it and restart the server it will resolve the issue.
As when we updrage the php to latest version that file may get stored to latest versions which is not required.
I used following commands:
cd /etc/php/7.3
sudo rm -rf mcrypt.so
sudo service apache2 restart
Just comment out all lines with .dll extensions because you are on Ubuntu. Ubuntu support .so files.
In php.ini under Dynamic Extensions the line extension=php_mysqli.dll was enabled.
I disabled it by adding a semi-colon at the head of the line ;extension=php_mysqli.dll.
Saved and exited php.ini. Restarted Apache.
This resolved the error for me.

Categories