PHP mysqli runs on command line but not on pages

Red Hat Linux Server, Apache 2.2, PHP 5.5.4

When I run this on the command line, everything seems fine:

php -r '$ mysqli = new mysqli ("127.0.0.1", "un", "pw", "things", "3306");

At the same time, I have a .php document that does not start. I get this error ...

PHP Fatal error: class 'mysqli' not found in [/path/to†/vars.php on line 2

from this code:

<?php $mysqli = new mysqli("localhost", "un", "pw", "things", "3306"); ?> 

Other .php pages (which don't use mysqli) work fine. Any idea what is going on here? Thanks in advance.

+4
php mysqli apache
Oct 10 '13 at
source share
1 answer

running php from the command line (CLI) is removed from the web server.

Specify mysqli extension in both.

Usually, if it is installed, you can go to "php.ini" and uncomment the line for "mysqli". On some installations, there is one copy of "php.ini" for Apache and another for the command line. I think both of them are somewhere under '/ etc / php5 /'.

0
May 17 '16 at 10:07
source share



All Articles