Upgrade to version 4.7.31 seems to have broken DAO.PHP
It sounds like you perhaps aren't using a supported version of PHP.  I would check your version; my guess is that you're on PHP 5.4, since 5.5 is the minimum supported version in Civi 4.7.31.

I would restore your site from a backup if you're not in a position to upgrade PHP immediately - but my advice is to try to upgrade PHP.  PHP 5.4 is known to be insecure and hasn't received security updates in almost 3 years.