Issue
I'm on Raspbian 9.
I installed php and php-mysql
>sudo sudo apt-get install php7.0-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.0-mysql is already the newest version (7.0.30-0+deb9u1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
But my php script throw an error, stating myscli class is not available
>php prodDataSender.php
PHP Fatal error: Uncaught Error: Class 'mysqli' not found in /home/pi/prodDataSender.php:12
Stack trace:
#0 {main}
thrown in /home/pi/prodDataSender.php on line 12
Here is the really simple line causing the error :
// Create connection
$conn = new mysqli($host, $user, $password, $db);
Here is a the php -i grep :
>php -i | grep mysql
Additional .ini files parsed => /etc/php/7.0/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
pi@valrb2:~ $
I tried :
reload/restart apache2 reboot Removing / Installing again php / php-mysql
Nothing works.
I don't know what to search now.
Edit :
If I add :
extension=mysqli.so
I get :
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mysqli.so' - /usr/lib/php/20151012/mysqli.so: undefined symbol: mysqlnd_connect in Unknown on line 0
PHP Fatal error: Uncaught Error: Class 'mysqli' not found in /home/pi/prodDataSender.php:12
Stack trace:
#0 {main}
thrown in /home/pi/prodDataSender.php on line 12
Solution
reinstalling php7.0-mysql with purge works: sudo apt-get purge php7.0-mysql && sudo apt-get install php-mysql
Please validate the output php -r 'phpinfo();' | grep -i mysqli
Answered By - sothish