I have commissioned a new Ubuntu 16.04 server with LAMP. PHP is 7.0. This line of php now throws a 500 internal error;

$result = new mysqli('localhost', 'user', 'pwd', 'dbase');

It works fine on my 14.04 PHP 5 server.

I have run

php -r 'phpinfo();' | grep -i mysqli

The results are

MysqlI Support => enabled
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off
API Extensions => mysqli,pdo_mysql

When I run phpinfo() via a browser, however, I see no sign of mysqli.

  • Is php7.0-mysql module installed with your php ? – George Udosen Dec 4 '16 at 12:56
  • I do php -m | grep -i mysql and get mysqli mysqlnd pdo_mysql – anthonyc Dec 4 '16 at 14:57
  • use ctrl + f in browser to find mysqli it should be there! Please just try again. – George Udosen Dec 4 '16 at 15:05
  • The only occurrences of 'mysql' in phpinfo() run from browser and using ctrl + f are in the PHP credits section. This is what is puzzling me. I can see the modules from the command line but not via the browser and phpinfo(). – anthonyc Dec 4 '16 at 15:39
  • Did you install the php7.0-mysql package? Then restart the web server and the PHP process? – Thomas Ward Dec 4 '16 at 16:58

Followed Thomas' advice. It did the trick. I installed php7.0-mysql. It told me I already had the most up-to-date package. I restarted Apache anyway and all was well.

sudo systemctl restart apache2.service

It may be because I installed Apache before php and never restarted Apache after php install. Restart fixed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.