PHP extensions couldn't load

Hello board,

I have FreeBSD 12 , Apache24 and PHP74.

I installed PHP extensions But my programs cant load them. For example:
Code:
# pkg info |grep session
php74-session-7.4.5            The session shared extension for php
And I get the following error in browser:
Code:
Uncaught Error: Call to undefined function session_cache_limiter()
Or :

Code:
# pkg info | grep mysql
php74-mysqli-7.4.5             The mysqli shared extension for php
php74-pdo_mysql-7.4.5          The pdo_mysql shared extension for php
And I get the following message:

Code:
 Uncaught Error: Call to undefined function mysql_connect()

How can I solve my problem?
 
The php code that you are try to run is for old PHP5 and some of it's functions are removed in the newer version of PHP7.


You can create a simple php info page to see all extensions using
echo "<?php phpinfo(); ?>" >> /usr/local/www/data/test.php
then put this test.php file under your data folder for example in /usr/local/www/apache24/data/ and then navigate to http://<hostname>/test.php

or run php -m to check all loaded modules
 
PHP is works find, my `php -m` is :

Code:
/usr/local/etc{136}# php -m
[PHP Modules]
bcmath
Core
ctype
date
dom
filter
gettext
hash
iconv
json
libxml
mysqli
mysqlnd
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zlib

[Zend Modules]
Zend OPcache


By the way , I use PDO for mysql_* functions and it can support them.
 
How did you install these extensions? Did you compile them from ports and enabled ZTS option when PHP (www/mod_php74) wasn't compiled with it or vice-versa?

The mysql_* functions do not exist anymore. They were implemented by the mysql extension, not PDO nor pdo_mysql.

Don't refer to PHP CLI's output if you have a problem in web context, consider phpinfo's output in the very same context.

Make sure to have display_startup_errors enabled. Also check Apache's error log.
 
I use PDO for mysql_* functions and it can support them.

PDO has a completely different interface to the mysql/mysqli extensions and does not support the old function names by default. Are you using a wrapper (e.g https://www.phpclasses.org/package/8221-PHP-Access-MySQL-databases-using-PDO-wrapper-functions.html) to re-create the mysql_* functions using PDO? (The "undefined function" error suggests not...)

The session_cache_limiter function looks like it should still exist if the session module is loaded. I would make sure your web server has been restarted (or php-fpm if you're running it that way), then make a simple php script like below to actually confirm php is running correctly via the web server and see the modules that are loaded -

phpinfo.php
Code:
<?php phpinfo();
 
I had a similar problem when upgrading from an older PHP to a newer one. I'd updated all of the php-* packages, but missed upgrading mod_php package. Once I'd removed the old mod_php and installed the new one, everything was fine, of course! :D
 
Back
Top