PHP 7.0 to PHP 5.6 on Ubuntu / Linux Mint

Parse error: syntax error, unexpected ‘new’ (T_NEW) in /usr/share/php/MDB2/Driver/pgsql.php on line 925

The problem is that MDB2 is not supported for PHP7.0
It is better to use PDO PHP PDO but if you cant then here is how to downgrade to PHP5.6.

dpkg -l | grep php| awk '{print $2}' |tr "\n" " "

I like to do it manually so copy the above output to the command

sudo apt-get purge libapache2-mod-php7.0 php php-common php-gettext php-mdb2 php-pear php-pgsql php-phpseclib php-xml php7.0 php7.0-cli php7.0-common php7.0-dev php7.0-fpm php7.0-gd php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-pgsql php7.0-readline php7.0-xml php7.0-zip 
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6

Verify php 5.6

php -v

PHP (cli)
Then restart apache2.0

sudo /etc/init.d/apache2 restart

Dont forget to install PEAR again

sudo apt-get install php-mdb2
apt-cache search mdb2
sudo apt-get install php-mdb2-driver-pgsql
sudo apt-get install php5.6-pgsql

Leave a Reply

Your email address will not be published. Required fields are marked *

Reload Image