Title: Database Cache causing 503 errors when upgrading to PHP 7
Last modified: October 28, 2018

---

# Database Cache causing 503 errors when upgrading to PHP 7

 *  Resolved [Francesco](https://wordpress.org/support/users/fcolombo/)
 * (@fcolombo)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/)
 * Hi,
 * I have a WordPress installation (4.9.8) with W3 Total Cache (0.9.7) on a LiteSpeed/
   Apache shared server and PHP 5.6. All is working fine.
 * In W3TC I have enabled: Page Cache (Disk: Enhanced), Minify (Disk), Database 
   Cache (Disk), and Browser Cache.
 * If I upgrade to PHP 7.2 (or 7.1 or 7.0), the website returns a 503 error (only
   for not logged-in users – the admin area is still accessible).
 * In my logs, I have this:
 *     ```
       PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /home/~/public_html/wp-includes/wp-db.php:1564
       Stack trace:
       #0 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_Wpdb.php(145): wpdb->db_connect(true)
       #1 /home/~/public_html/wp-includes/wp-db.php(592): W3TC\DbCache_Wpdb->db_connect()
       #2 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_Wpdb.php(252): wpdb->__construct('redacted', 'redacted', 'redacted', 'redacted')
       #3 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_WpdbInjection.php(38): W3TC\DbCache_Wpdb->default_initialize()
       #4 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_Wpdb.php(152): W3TC\DbCache_WpdbInjection->initialize()
       #5 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_Wpdb.php(379): W3TC\DbCache_Wpdb->initialize()
       #6 /home/~/public_html/wp-content/plugins/w3-total-cache/DbCache_WpdbInjection_QueryCaching.php(229): W3TC\_CallUnderlying->initialize()
        in /home/~/public_html/wp-includes/wp-db.php on line 1564
       ```
   
 * Which makes me think that W3TC’s Database Cache is struggling when on PHP 7.
 * Reverting back to PHP 5.6 fixes the problem.
 * Am I missing anything obvious, and does anyone know if there’s any quick win 
   to get around this?
 * Thanks in advance!

Viewing 11 replies - 1 through 11 (of 11 total)

 *  [bgdstr](https://wordpress.org/support/users/bogdanstratulat/)
 * (@bogdanstratulat)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10825872)
 * is the plugin updated to the latest version? Please make sure to update to 0.9.7.
 *  Thread Starter [Francesco](https://wordpress.org/support/users/fcolombo/)
 * (@fcolombo)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10827727)
 * Hi, thank you for your reply. Yes, the plugin is updated to the latest version.
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10827797)
 * Hello,
 * If you disable DB caching does the issue persists?
 *  Thread Starter [Francesco](https://wordpress.org/support/users/fcolombo/)
 * (@fcolombo)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10830734)
 * Hi [@vmarko](https://wordpress.org/support/users/vmarko/) and [@bogdanstratulat](https://wordpress.org/support/users/bogdanstratulat/)
 * I can confirm that disabling DB caching and upgrading to PHP 7.2 works just fine.
 * It’s when I re-enable DB caching that the 503 errors start.
 * Thanks for your help.
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10830798)
 * Hello,
    If you are using Database Cache method: Disk, Try using other, memory
   based caching solution like memcached
 *  Thread Starter [Francesco](https://wordpress.org/support/users/fcolombo/)
 * (@fcolombo)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10831175)
 * The website is on a shared server, so only Disk caching is available unfortunately.
 * Do you have any other suggestions?
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10831446)
 * Hello,
 * You need to check if your MySQL extension is enabled
 * You can set
    define(‘WP_USE_EXT_MYSQL’, true); in your wp-config.php to make 
   WordPress use the mysqli extension.
 *  Thread Starter [Francesco](https://wordpress.org/support/users/fcolombo/)
 * (@fcolombo)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10832013)
 * Thanks for the suggestion, [@vmarko](https://wordpress.org/support/users/vmarko/).
 * Would `define(‘WP_USE_EXT_MYSQL’, true);` force WP to use MySQL by default, rather
   than MySQLi?
 * “Use MySQLi when available by default” was introduced in 4.9.2 and I feel that
   forcing to use MySQL is like backtracking – Are there any plans for the DB cache
   to work using MySQLi too?
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10835135)
 * Hello,
 * Yes, you should use it when available. You should ask your hosting company to
   check the PHP and MySQL config settings
    Using `define(‘WP_USE_EXT_MYSQL’, true);`
   is a workaround if MSQLi is not available.
 *  Thread Starter [Francesco](https://wordpress.org/support/users/fcolombo/)
 * (@fcolombo)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10856663)
 * Thank you.
 * On my server, the `mysqli` extension was enabled.
 * I ticked it off and selected `nd_mysqli` instead, and the problem is solved.
 * Thanks again for all your help!
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10856720)
 * Hello [@fcolombo](https://wordpress.org/support/users/fcolombo/),
 * Glad to know that the issue is resolved.
 * Please take some time and post a 5-star review here if convenient. This shouldn’t
   take more than a couple of minutes. Our goal is to continue offering a top-notch
   product, and your review could greatly help us to continue doing so.
    Best regards

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Database Cache causing 503 errors when upgrading to PHP 7’ is closed 
to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 11 replies
 * 3 participants
 * Last reply from: [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/database-cache-causing-503-errors-when-upgrading-to-php-7/#post-10856720)
 * Status: resolved