r/PHPhelp • u/geeered • Dec 05 '23
Solved PHP 5.6.40 MYSQL functions not working? - "Call to undefined function mysqli_connect()"
The DLL loads fine, but I still get Fatal error: Call to undefined function mysqli_connect() when testing it.
I have to use a version 5.x on this internal system for the moment - at some point the codebase it will be updated, to work with newer versions but don't have the time right now.
php -m shows it is the loaded
php -i shows
Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password
API Extensions => mysql,mysqli,pdo_mysql
mysqli
MysqlI Support => enabled
Client API library version => mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $
Active Persistent Links => 0
Inactive Persistent Links => 0
Active Links => 0
Directive => Local Value => Master Value
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off
Anything else I should be looking for?
4
u/MateusAzevedo Dec 05 '23
It's possible to have different settings for CLI and web, so you may have it enable on
php -ibut not from a web request.Use
phpinfo()on a php page to be sure on what's enabled in that context, specially which ini file is in use.2
u/allen_jb Dec 05 '23
Make sure you're looking specifically for "mysqli" here. Any other extensions with "mysql" in the name are not what you're looking for (eg. mysqlnd, mysql, pdo_mysql)
Is only one PHP version installed on the affected system, or are there multiple versions? (Could your code be running in a different version, or under different configuration)?
Always run
php -iorphpinfo()using the same command / method / context that your code is running in.1
u/DmC8pR2kZLzdCQZu3v Dec 05 '23
You’ve been too busy for 5 years now. That’s when this version lost support. I doubt that’ll change unless you expand your team. Even then upgrading may never happen because the longer you wait the bigger the task becomes as you have to traverse more deprecations and major refactoring changes. If by “internal” you mean it’s not on the public internet, I’m glad about that, at least. I know management is often times extremely unhelpful in supporting this type of upgrade work, but often times the legal department won’t be happy with the liability once they are made fully aware of its extent.