0

Normally, in apache via mod php it works perfectly fine, but if I try function_exists('mysqli_init'), function does not exist.

Other errors shown:

Call to undefined function mysqli_connect() Class 'MySQLi' not found in <file>

Why MySQLi isn't working and how to fix it? Thanks!

Command used to run test:

vendor/bin/tester -c /etc/php5/apache2 -p php
david8
  • 444
  • 9
  • 23
  • Be careful, PHP CLI and PHP web have two different configurations so what appears while testing from command line may be different for web. Far better to make a webpage with the following in it: It's plausible mysqli is not configured for CLI on your server, but is for web. Goodluck! – Dan Belden Jun 27 '15 at 08:26
  • This may also help: http://stackoverflow.com/questions/11585399/command-line-php-mysqli-fails-but-works-via-web-server-and-works-in-local – Dan Belden Jun 27 '15 at 08:28

2 Answers2

1

Try running ./vendor/bin/tester -c /etc/php5/apache2 -p php --info to see which php.ini file and PHP extensions are loaded.

Most-likely the you are going to find out that the MySQLi extension is not loaded because the /etc/php5/apache2/php.ini does not contain the necessary option.

The correct solution is to create specific php.ini for your project with necessary extensions.

See also official documentation:

The Tester runs PHP processes with -n option, so no php.ini is loaded (not even that from /etc/php/conf.d/*.ini in UNIX)

Jan Tvrdík
  • 355
  • 2
  • 11
0

With tester -c parameter, you need to provide path to php.ini file, not folder containing it.

Also tester resets php environment for repeatable result. It is better idea provide own php.ini which only defines needed extesions:

[PHP}
extension=mysqli.so
Tomáš Jacík
  • 645
  • 4
  • 12