Error with mysql_connect() at installation time

Hello,

I have seen other posts mentioning the Fatal PHP error with mysql_connect(). I did modify the file config.inc.php to mention mysqli as the device driver, hoping to solve this issue. However, I still get the fatal PHP error when trying to do a fresh installation:

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /var/www/html/ojs2/lib/pkp/lib/adodb/drivers/adodb-mysql.inc.php:456\nStack trace:\n#0 /var/www/html/ojs2/lib/pkp/lib/adodb/adodb.inc.php(558): ADODB_mysql->_connect(‘localhost’, ‘ojs2’, ‘’, ‘ojs2’)\n#1 /var/www/html/ojs2/lib/pkp/classes/db/DBConnection.inc.php(151): ADOConnection->Connect(‘localhost’, ‘ojs2’, ‘’, ‘ojs2’, false)\n#2 /var/www/html/ojs2/lib/pkp/classes/db/DBConnection.inc.php(126): DBConnection->connect()\n#3 /var/www/html/ojs2/lib/pkp/classes/db/DBConnection.inc.php(113): DBConnection->initConn()\n#4 /var/www/html/ojs2/lib/pkp/classes/db/DBConnection.inc.php(55): DBConnection->initCustomDBConnection(‘mysql’, ‘localhost’, ‘ojs2’, ‘’, ‘ojs2’, false, ‘utf8’)\n#5 /var/www/html/ojs2/lib/pkp/classes/install/PKPInstall.inc.php(77): DBConnection->__construct(‘mysql’, ‘localhost’, ‘ojs2’, ‘’, ‘ojs2’, false, ‘utf8’)\n#6 /var/www/html/ojs2/lib/pkp/classes/install/Installer.inc.php(178): PKPInstall->preInstall()\n#7 /var/www/html/ojs2/lib/pkp/classes/in in /var/www/html/ojs2/lib/pkp/lib/adodb/drivers/adodb-mysql.inc.php on line 456,

I’m installing on ubuntu 18 with PHP 7.3.

What else should be done?

Hi @h.m,

Do you have the mysqli enabled in the php.ini as well?

Regards, Primoz

  1. Check if your php.ini has the mysqli enabled

$ php --ini | grep “Configuration File” // To see the correct file to check

  1. Change the driver on your config.inc.php

  2. Restart apache2

$ systemctl restart apache2

Yes, I do have mysqli enabled:

php -m | grep -i mysqli

returns mysqli

And I did modify config.inc.php:

[database]

driver = mysqli

But I still see this error:

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /var/www/html/ojs3/lib/pkp/lib/adodb/drivers/adodb-mysql.inc.php:456

which indicates that ojs is ignoring my request to use mysqli and it instead goes for mysql.

Do you have other versions of PHP installed? Have you installed php7.X-mysql ? That’s all I can think for now…

I don’t have other versions. To make sure my installation is clean, I installed a fresh Ubuntu 18 on a VM and did all the installation steps. I installed apache2, php7, and mysql 14.4. I also cloned a fresh copy of OJS from github. This time, the configuration file on OJS already had mysqli as the driver. I still get the same error. It seems like OJS keeps ignoring my configuration to use mysqli.
Anything else I should try?

I could install the system only with postgres DB as the driver. I did try installation on a macOS and I got the same error. Bizarre.

Hi @h.m,

Could you post the full stack trace? It looks like it’s cut off in your earlier post.

Regards,
Alec Smecher
Public Knowledge Project Team

I tried again doing all the steps carefully and it worked with mysqli too. I’m not sure what caused it really.