How to Fix Call to undefined function mysql_connect()

How to Fix Call to undefined function mysql_connect()

As the name suggests, Fatal error: Uncaught Error: Call to undefined function mysql_connect() means the database on the system you are using is not detected, is experiencing an error, or you have not enabled the required extension.

To resolve this issue, you must check whether the database on your server is actually running. However, if you are using hosting, especially with the control panel cPanel, you can resolve it by following the tutorial we will discuss here.

How to Fix Call to undefined function mysql_connect()

Before we discuss further, this tutorial is only for those using the cPanel control panel with the PHP Selector feature. If you do not have PHP Selector, you can change the PHP version from the MultiPHP Manager page and ensure you use the ea version, not the alt.

1. Log in to cPanel Hosting

Usually, you can log in to cPanel via https://namadomain/cpanel, or by using one of the following links

  • https://namadomain:2083
  • https://cpanel.namadomain
  • https://IP_Server:2083

*make sure to change yourdomain with your actual domain name, for example wpgan.com. If you are using the Server_IPmethod, make sure to change it to your Server IP.

2. Open the PHP Selector Page

To open PHP Selector, you can use the search feature in cPanel to speed up the process

3. Enable the Extension

Once you are on the PHP Selector page, open the Extensionstab, then make sure one of the following extensions is enabled

  • mysqli
  • nd_mysqli
  • mysqlnd
  • nd_pdo_mysql

If it is not enabled, you just need to check the option, and a success message will appear

4. Try Accessing Your Website

Once the extension activation process is complete, you can try accessing your website again, and the Fatal error: Uncaught Error: Call to undefined function mysql_connect() should no longer appear.

If it still shows an error, you can try changing the PHP version used on your domain using MultiPHP Manager and ensure you use the ea.

If both methods do not work, it is recommended to contact your hosting provider. If you are using your own server, ensure the MySQL or MariaDB service is running normally.

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...