Fixing the "Database Server Error" When Typecho Runs on PHP 7+

When I switched this blog's Typecho install to PHP 7.0 or newer, every page threw a "Database Server Error." Digging around, it looked like Typecho simply wasn't compatible with PHP 7.0. The server also hosts a project on PHP 5.6, which is why the blog had been on 5.6 all along. With the problem in front of me, I searched and found a fix.

config.inc.php gives it away. Open the file and find:

$db = new Typecho_Db('Mysql', 'typecho_');

and change it to:

$db = new Typecho_Db('Pdo_Mysql', 'typecho_');

After the swap, reload the front end and the admin panel and both work normally.

Leave a Comment

Comments No Comments

Table of Contents