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

I'm in big trouble. I installed the nulled version of the woocommerce cart based shipping plugin and found it was not suitable for my requiremnet and removed that plugin from the plugins area. After removing this plugin, my site went offline. This keeps showing me a 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 to replace all main files except wp-config.php and wp-content folder. However, I am getting the same error.

Also, I tried to rename the plugins folder, but there is an error.

Guys, can you suggest me how I can get my site back.

+8


source to share


5 answers


Possible error sources:

  • As of PHP 7, functions mysql_*

    have been removed, see the Official Overview of PHP MySQL Drivers .
  • You are using PHP 5.x and did not include the extension mysql

    , but instead mysqli

    and / or pdo_mysql

    .

You can install



define('WP_USE_EXT_MYSQL', true);

      

in your file wp-config.php

for WordPress to use the mysqli extension.

+6


source


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



Just enable "mysqli" in the php version of your choice if you are using cPanel.

+1


source


The error seems simple, mysql_*

features are not included. Check with help phpinfo()

if these features are indeed disabled, and if so, enable it. If not, there are some problems with the code you are using, but if you replaced all the files while writing, this is most likely the first option.

0


source


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

define('WP_USE_EXT_MYSQL', true);

      

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

If not, you can mark the extension nd_mysqli

in PHP 7 config and disable the extension mysqli

on Cpanel -> Select PHP version.

Source:

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

Hope this helps. :)

0


source


I ran into this issue when upgrading from PHP 5 to PHP 7 (on Windows). The problem was that the mysqli

PHP extension was not included. If mysqli is not available, Wordpress 5+ detects this and tries to connect to the database with legacy calls instead mysql_connect()

. This leads to a very misleading error message that the mysql_connect () function is not available (since we don't want this function).

In php.ini make sure the extension_dir

mysqli extension is installed (use full directory name) and enabled

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

      

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

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

      

0


source







All Articles