0

I want to test PHP script that will execute a command line command. But I get the following error in the shell.

The site that I've design locally works perfectly

Fatal error: Call to undefined function mysqli_init() in /Applications/mampstack-5.6.19-0/frameworks/codeigniter/system/database/drivers/mysqli/mysqli_driver.php on line 136

A PHP Error was encountered

Severity:    Error
Message:     Call to undefined function mysqli_init()
Filename:    /Applications/mampstack-5.6.19-0/frameworks/codeigniter/system/database/drivers/mysqli/mysqli_driver.php
Line Number: 136

Backtrace:

I'm using Bitnami MAMP Stack 5.6.19.0 with Codeigniter 3.0

Juan-Emil Saayman
  • 198
  • 1
  • 3
  • 18

1 Answers1

0

You need activate the php_mysqli extension in the php.ini file that controls the PHP CLI, its not the same one as controls PHP Under the web server.

From the terminal do

php -i

And look for the parameter Loaded Configuration File and Configuration File (php.ini) Path that will tell you which php.ini file to amend and where it lives.

If one does not exist, as I believe is the case on some installs, then you know where to create one by looking at the Configuration File (php.ini) Path parameter.

You could start by copying your web server version into this directory, but do a quick sanity check on it as well

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • I get the following when I run the command. `Configuration File (php.ini) Path => /opt/local/etc/php5 Loaded Configuration File => (none)` – Juan-Emil Saayman Sep 08 '16 at 08:32
  • Then you will have to make a `php.ini` in the `/opt/local/etc/php5` to configure the CLI environment to how you want it. For now that might just be to copy your web server version to there. Do a quick sanity check on what is in there though – RiggsFolly Sep 08 '16 at 08:48
  • Could you I've me some guidance to implement the solution that you are proposing. – Juan-Emil Saayman Sep 08 '16 at 10:45
  • Please note that you are using a bitnami stack. In order to load the stack environment, please execute `installdir/use_mamp`. Retest your issue, please! – David González Ruiz Oct 06 '16 at 11:28