Errors related to "mysql_connect" typically indicate that the script is outdated. Here's an example of the error:
PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/user/public_html/script.php:7
This error is most commonly caused by the use of a modern PHP version on a website that uses the function, "mysql_connect" which was deprecated in PHP 5.5 and removed in PHP version 7.0. For more information, please review the official PHP documentation.
There are two solutions to this issue:
1. (Recommended) The website developer should review all of the PHP files and update the website code to be compatible with supported versions of PHP. Individually, "mysql_connect" should be replaced with "mysqli_connect."
2. (Not recommended) The website's PHP version can be changed via MultiPHP Manager to use an older one that supports mysql_connect such as PHP version 5.4. You may be able to use PHP 5.6, but you may see deprecation warnings.
If the website is configured properly to use PHP 5.6 or older via MultiPHP Manager or CloudLinux's PHP selector, and you see the correct version in a phpinfo page, but are still seeing this error, this means the extension is not loaded. Here are some possible causes:
1. The mysqlnd extension is not installed.
To correct this, use the EasyApache 4 interface to install the correct extension on the PHP version, or use yum.
yum install ea-php56-php-mysqlnd
2. The website was configured with
suPHP_ConfigPath in EasyApache 3
Please reference The cPanel PHPRC PHP Patch for EasyApache 4 documentation.
- We strongly recommend that you do not set the
suPHP_ConfigPathdirective or set the PHPRC environmental variable. Unexpected behavior may occur.
The solution here would be to modify the .htaccess file in the document root or above and remove the "suPHP_ConfigPath" directive. This causes only the user's php.ini file to be loaded instead of all of the inis required to load the extensions.
3. The extension is not enabled in PHP Selector
If the server uses CloudLinux™, and MultiPHP Manager is set to "Inherit," and the user is in CageFS, this means that PHP Selector takes precedence. You will want to go into the PHP Selector options and make sure the "mysqlnd" extension is enabled.