wesupport

Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

PHP fatal error call to undefined function mysql_connect() – How to fix it

by | Jun 18, 2020

Webmasters and website owners often upgrade PHP to the latest version to avoid security vulnerabilities. This sometimes causes compatibility errors, and one such error is “PHP fatal error call to undefined function mysql_connect()”.

As a part of our Server Management Services, we help our customers to fix such PHP errors.

Here, let’s discuss how to fix the PHP fatal error call to undefined function mysql_connect()

 

What is a PHP fatal error?

 

Using older versions of PHP may expose the website to security vulnerabilities and more importantly, bugs that are fixed in the recent versions.

So it is a better idea to upgrade the PHP version to the latest one. However, it is also important to prevent PHP fatal errors on your website.

PHP Fatal Errors also known as Critical Errors can occur after the PHP upgrade​. This error stops/terminates the execution of scripts.

The mysql_connect() PHP  fatal error may often occur after upgrading your app to PHP 7+. It will try to use “mysql_connect()” functions of php5 in php7. However, mysql_* functions are completely removed from PHP 7+

Also, Fatal error: Uncaught Error: Call to undefined function mysql_connect() error on WordPress site or dashboard looks like,

 

How to fix the PHP fatal error call to undefined function mysql_connect() error

 

After upgrading your PHP version to PHP 7+, there is a chance that you will have the following error:

Fatal error: Uncaught Error: Call to undefined function mysql_connect()

This is due to the removal of the mysql_connect function from PHP 7+ versions.

Let’s see how our Support Engineers fixed the PHP fatal errors

 

1. Upgrade custom code and WordPress plugins or theme

 

Initially, we’ll identify whether the site is WordPress or using custom code.

If it is WordPress, the main reason could be compatibility issues. The WordPress theme or plugin may not be compatible with higher PHP versions.

So, we will enable the debug option in wp-config.php and find which WordPress plugin or theme is not compatible with PHP 7+. Then, we will recommend them to upgrade/replace the plugin and theme.

If the site is using custom code, then our developer team will help the customers to make the code compatible with the new PHP version.

This solved the issue.

 

2. Use MySQLi or PDO

 

Fatal error: Uncaught Error: Call to undefined function mysql_connect() error can be fixed by the use of MySQLi or PDO.

Many customers are using PHP 7.3 version and WordPress latest version. However, they will get the same error after upgrading.

So, we solved the error by enabling the nd_mysqli extension in the PHP configuration and disabling the mysqli one.

 

How we fix PHP Fatal error: require_once()

 

Another issue that we commanly dealing with is PHP Fatal error: require_once(): Failed opening required ‘Mail.php’ (include_path=’.:/usr/share/pear:/usr/share/php’)

Recently, one customer had an issue while sending an email by using PHP mail function with SMTP after upgrading PHP from PHP 5.6 to PHP 7+.

On checking, we have found that the error happened due to an incorrect path to Mail.php. He has created the file mail.php instead of Mail.php and specified as require_once(‘Mail.php’)

So we have renamed the file name to Mail.php and solved the error

[Need assistance to fix PHP Fatal errors? – our Support Engineers will help you.]

 

Conclusion

In short, php fatal error call to undefined function mysql_connect() error occurs after PHP version upgrade. This is due to the removal of the mysql_connect function from PHP 7+ versions. Today, we saw how our Support Engineers fixed the PHP fatal errors.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags