Reputation: 47
On a new server I installed PHP 7.0.10 and mysql. When I try to connect to the database via a php file using mysqli_connect() it gives the error message
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /opt/http/blabla/src/class_db.php:19 Stack trace: #0 /opt/http/blabla/src/main.php(17): _Db->connect() #1 {main} thrown in /opt/http/blabla/src/class_db.php on line 19
This is caused because PHP cannot load the mysql shared object:
[root@nl2 httpd]# php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64 /php/modules/mysqli.so' - /usr/lib64/php/modules/mysqli.so: symbol mysql_change_user, version libmysqlclient_18 not defined in file libmysqlclient.so.18 with link time reference in Unknown on line 0 PHP 7.0.11 (cli) (built: Sep 17 2016 09:23:18) ( NTS )
Both libraries exist:
[root@nl2 httpd]# ls -l /usr/lib64/php/modules/mysqli.so /usr/lib64/php/modules/mysqli.so
-rwxr-xr-x 1 root root 141856 Sep 17 11:39 /usr/lib64/php/modules/mysqli.so
-rwxr-xr-x 1 root root 141856 Sep 17 11:39 /usr/lib64/php/modules/mysqli.so
Some configuration information:
# yum list installed
php70w.x86_64 7.0.10-1.w7
php70w-cli.x86_64 7.0.10-1.w7
php70w-common.x86_64 7.0.10-1.w7
php70w-devel.x86_64 7.0.10-1.w7
php70w-gd.x86_64 7.0.10-1.w7
php70w-mysql.x86_64 7.0.10-1.w7
php70w-opcache.x86_64 7.0.10-1.w7
php70w-pdo.x86_64 7.0.10-1.w7
php70w-process.x86_64 7.0.10-1.w7
mysql55w.x86_64 5.5.50-1.w
mysql55w-devel.x86_64 5.5.50-1.w
mysql55w-libs.x86_64 5.5.50-1.w
mysql55w-server.x86_64 5.5.50-1.w
# cat /etc/php.d/mysqli.ini
;Enable mysqli extension module
extension=mysqli.so
extension=php_mysqli.so
Any suggestions? Thanks.
Upvotes: 3
Views: 8316
Reputation: 1639
I would comment, but I don't have enough points. Have you tried:
yum -y install php70w-mbstring php70w-mcrypt
And then connecting using:
$mysqli = new mysqli('ip', 'user', 'pass', 'db', port);
I think it's an issue of not enough PHP installed!
Upvotes: 2