Thomas
Thomas

Reputation: 427

Wordpress Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /wp-includes/wp-db.php:1570

I am in big trouble. I installed a nulled version of woocommerce cart based shipping plugin and i found it not relevant according to my requiremnet and deleted that plugin from plugins area. After deleting that plugin my site went down. Its continuously showing me Fatal error:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/dev/public_html/new/wp-includes/wp-db.php:1570
Stack trace:
#0 /home/dev/public_html/new/wp-includes/wp-db.php(658): wpdb->db_connect()
#1 /home/dev/public_html/new/wp-includes/load.php(404): wpdb->__construct('dev_test', 'password', 'dev_test_ne...', 'localhost')
#2 /home/dev/public_html/new/wp-settings.php(107): require_wp_db()
#3 /home/dev/public_html/new/wp-config.php(82): require_once('/home/dev/p...')
#4 /home/dev/public_html/new/wp-load.php(37): require_once('/home/dev/p...')
#5 /home/dev/public_html/new/wp-blog-header.php(13): require_once('/home/dev/p...')
#6 /home/dev/public_html/new/index.php(17): require('/home/dev/p...')
#7 {main} thrown in /home/dev/public_html/new/wp-includes/wp-db.php on line 1570

I tried replacing all core files excluding wp-config.php and wp-content folder. Still I am getting the same error.

Also, i tried renameing plugins folder but the error is there.

Can you guys suggest me how i can get my site back.

Upvotes: 18

Views: 53317

Answers (9)

Laurent Debricon
Laurent Debricon

Reputation: 4517

sudo apt-get install php7.4-mysql
sudo service apache2 restart

Upvotes: 0

Sudhir Dixit
Sudhir Dixit

Reputation: 1

i had same kind of issue for my web hosting client at magicworkshost , i have updated php version from 5.6 to 7.3 and issue resolved successfully.

Thanks

Upvotes: 0

Misophoniq
Misophoniq

Reputation: 39

Just registered to give a big thank you for the solution of enabling mysqli. I have been struggling to get WordPress running on a Synology for the past 3.5 hours and this finally fixed my dreaded "The site is experiencing technical difficulties."

For any other Synology users ending up in this topic after trying to find a solution, to fix this on Synology, you need to...

  • Go to Web Station
  • Select PHP Settings
  • Double-click the PHP profile you are using (or click once and choose [Edit])
  • Select General Settings and scroll to the extensions list
  • Find mysqli and enable by placing a checkmark
  • Push the [OK] button (no restart required)

Upvotes: 3

Paul R
Paul R

Reputation: 1

Just had a similar problem with a cpanel multiphp instance. Tried just about everything but while cpanel/whm was saying all was fine, the site would crash when 7.x was activated.

In the end, it was the .htaccess file. We renamed and let Cpanel regenerate and all is good.

Hope this helps someone out there as it took some time to resolve here.

Upvotes: 0

Robb Hoff
Robb Hoff

Reputation: 1910

I encountered this problem upgrading from PHP 5 to PHP 7 (on Windows). The problem was mysqli PHP extension was not enabled. If mysqli is not available Wordpress 5+ detects this and will instead attempt to connect to the database with deprecated mysql_connect() calls. This leads to a very misleading error message about mysql_connect() function not being available (since we don't want this function).

In php.ini make sure extension_dir is set (use full directory name) and mysqli extension is enabled

extension_dir = "C:\php-7.3.10\ext"
...
extension=mysqli

To double check what extensions are active you can run the following code

<pre>
<?php print_r(get_loaded_extensions()); ?>
</pre>

Upvotes: 27

Simon
Simon

Reputation: 305

Please check your wp-config.php file for the following line:

define('WP_USE_EXT_MYSQL', true);

If you find it, delete the line. Your problem should be fixed.

If not, you can tick nd_mysqli extension in the PHP 7 configuration, and disable the mysqli extension on Cpanel -> Select PHP version.

Source:

https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/

Hope this helps. :)

Upvotes: 3

Schakko
Schakko

Reputation: 164

Possible error sources:

You can set

define('WP_USE_EXT_MYSQL', true);

in your wp-config.php file to make WordPress use the mysqli extension.

Upvotes: 9

It happens for me when I switch from 5.6 php to 7.0.

Just enable "mysqli" in your select php version if you use cPanel.

Upvotes: 6

Ryosaku
Ryosaku

Reputation: 465

The error seems be simple, mysql_* functions are not enabled. Check with phpinfo() if these functions are truly disabled, and if yes, enable it. If no, there are some problems in the code that you are using, but if you have replaced all files as you write, is most probably the first option.

Upvotes: 0

Related Questions