WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: PHP Warning: Unable to load dynamic libraries related to mysql  (Read 2992 times)

Offline Yarpi

  • Newbie
  • *
  • Posts: 13
PHP Warning: Unable to load dynamic libraries related to mysql
« on: January 05, 2024, 09:48:34 AM »
Hello,

on my CorePlus, I'm trying to implement a web server but I can't communicate with mysqld, the PHP error log report some warning:

Code: [Select]
PHP Warning:   PHP Startup: Unable to load dynamic library 'ffi' (tried: /usr/local/lib/php/extensions/ffi (/usr/local/lib/php/extensions/ffi: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/ffi.so (libffi.so.7: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:   PHP Startup: Unable to load dynamic library 'hash' (tried: /usr/local/lib/php/extensions/hash (/usr/local/lib/php/extensions/hash: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/hash.so (/usr/local/lib/php/extensions/hash.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:   PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/local/lib/php/extensions/mysqli (/usr/local/lib/php/extensions/mysqli: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/mysqli.so (/usr/local/lib/php/extensions/mysqli.so: undefined symbol: mysqlnd_global_stats)) in Unknown on line 0

PHP Warning:   PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/local/lib/php/extensions/pdo_mysql (/usr/local/lib/php/extensions/pdo_mysql: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/pdo_mysql.so (/usr/local/lib/php/extensions/pdo_mysql.so: undefined symbol: mysqlnd_allocator)) in Unknown on line 0


I've found these files with
Code: [Select]
find / -iname mysqli.so except one that is hash.so. Anyway permissions for the other files are 755 and I have changed them in 777. Any suggestion on how to solve the problem, it seems that without these extensions it's not possible query the database.


The only error reported is:

Code: [Select]
PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in ...mycode.php
What can I do?

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 764
Re: PHP Warning: Unable to load dynamic libraries related to mysql
« Reply #1 on: January 05, 2024, 09:55:07 AM »
@Yarpi: Please indicate the version of TinyCore you're using and the version of PHP and MySQL/MariaDB you installed.

Offline Yarpi

  • Newbie
  • *
  • Posts: 13
Re: PHP Warning: Unable to load dynamic libraries related to mysql
« Reply #2 on: January 05, 2024, 10:29:19 AM »
I forgot sorry.

Here it is:

CorePlus 14, kernel version 6.1.2, php 7.4, mariadb-10.4


Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: PHP Warning: Unable to load dynamic libraries related to mysql
« Reply #3 on: January 05, 2024, 11:06:47 AM »
Which extensions have you loaded? In particular, have you loaded php-7.4-ext? Keep in mind that PHP 7.4 is End of Life, there will be no more bug or security fixes. You should use the latest version 8.3 if you can.

Offline Yarpi

  • Newbie
  • *
  • Posts: 13
Re: PHP Warning: Unable to load dynamic libraries related to mysql
« Reply #4 on: January 05, 2024, 12:10:33 PM »
Yes, I have loaded the php-7.4-ext, first of all other php module like: php-7.4-cgi.tcz, php-7.4-cli.tcz, php-7.4-mod.tcz and most probably I will update the php to 8 in the future.

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: PHP Warning: Unable to load dynamic libraries related to mysql
« Reply #5 on: January 05, 2024, 01:31:03 PM »
In the sample php.ini file it says what extensions you need to load yourself for each of the different modules you enabled. Have you loaded those? The php-ext extension does not have a way to know which extensions you have enabled. It would be a significant memory hit to load every dependency for every php extension even when they're not being used.

Where did you get your php.ini file? The hash extension is built in as of PHP 7.4, so the fact that your file is trying to load it says your php.ini file is from a version of PHP before 7.4. The mysqli extension requires the mariadb client, the mysqlnd extension uses a PHP supplied built in native client. Have you tried that one?

Offline Yarpi

  • Newbie
  • *
  • Posts: 13
Re: PHP Warning: Unable to load dynamic libraries related to mysql
« Reply #6 on: January 06, 2024, 05:39:02 AM »
I think I got my php.ini file from an older xampp installation on ubuntu 18, it was my previous web server and if my memory serves, I was using php 7.4. However I should have loaded all the requested extensions, can I share the php.ini here, if you want. (The sample and my version of php.ini are almost the same)

Anyway is the error to mysqli_connect() that is blocking the communication with the DB, isn't it?

But I load the mariadb-10.4-client.tcz after mariadb-10.4.tcz and I didn't try the built in native client because I don't know how to use it, sincerly I didn't know it exists.

Offline Yarpi

  • Newbie
  • *
  • Posts: 13
Re: PHP Warning: Unable to load dynamic libraries related to mysql
« Reply #7 on: January 26, 2024, 12:06:07 PM »
Hello everyone,

I found the solution to my issue, in the php.ini you need to uncomment mysqlnd. After that you need to load the module php-7.4-fpm.tcz and obviously all the php modules related.

It wasn't a tce bug, but it was a misconfiguration of my php.ini. The only problem I'm encountering right now is that the function session_start(), to start a php session is unknown.

If you had a solution to session_start() I would appreciate it.

Thank you.

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 764
Re: PHP Warning: Unable to load dynamic libraries related to mysql
« Reply #8 on: January 26, 2024, 12:52:43 PM »
PHP 7.4 -- IF memory serves, there's a session module that needs to be enabled if it was compiled externally.  Search for the word session in php.ini and it'll likely lead you in the right direction.

Offline Yarpi

  • Newbie
  • *
  • Posts: 13
Re: PHP Warning: Unable to load dynamic libraries related to mysql
« Reply #9 on: February 02, 2024, 12:16:28 PM »
Thank you, and sorry for my bad use of english expressions. I'm not a native speaker.

If I can't find the module, I can always compile php from scratch. We can mark this thread as solved.