How to enable mysqli support for PHP's CLI
Call to undefined function mysqli_connect()
Means the mysqli exension is not loaded.
I've reviewed /etc/php5/cli/php.ini AND /etc/php5/apache2/php.ini and have found no difference.
I would be very surprised if they were same. But in both cases, these are likely to be structured to work with extesnions distributed via packages - i.e. the ini file containing the directive to load the mysqli so extension will likely reside elsewhere and be included (or not) from these files.
Configuration File (php.ini) Path: /usr/local/lib
You have a Frankenstein system. You need to clean this up. Either use the distro's packaged apps or install apps from tarball. Don't use tarballs unless you know what you're doing. Don't mix and match unless you really know what you are doing.
- Delete the tarball PHP files
- reinstall the Ubuntu PHP cli
- reinstall the Ubuntu PHP mysqli extension
How can I enable the MySQLi extension in PHP 7?
I got the solution. I am able to enable MySQLi extension in php.ini. I just uncommented this line in php.ini:
extension=php_mysqli.dll
Now MySQLi is working well. Here is the php.ini
file path in an Apache 2, PHP 7, and Ubuntu 14.04 environment:
/etc/php/7.0/apache2/php.ini
By default, the MySQLi extension is disabled in PHP 7.
Command line php mysqli fails but works via web server and works in local
I found that mysqli was not installed with PHP and ran the following command:
>php -i
This returned the phpinfo() and found no mention of mysqli. I then ran the 'yum' command to install php-mysqli:
>yum install php-mysqli
After this the script worked successfully. Hope this helps others that might run into similar.
How to install MySQLi on MacOS
MySQLi is part of PHP. There should be a php-mysqli type package available, or you can take the PHP source and recompile that mysqli enabled. You may already have it installed, but it's done as a module and is disabled. Check your php.ini for extension=mysqli.so
or similar. it may be commented out, or the .so file is present in your extensions directory but not linked to PHP via that extension= directive.
Enable mysqli in my in-webserver copy of php
From your comments it appears your extension_dir
was set to /usr/lib64/php/modules
but this folder did not exist on your system.
On your system the mysqli.so module was actually found in /usr/lib/php5/20121212/mysqli.so
To resolve the issue, you can set the extension_dir
to /usr/lib/php5/20121212
so that the extension=mysqli.so
line is able to find the shared object.
Related Topics
Warning: Preg_Match() [Function.Preg-Match]: Unknown Modifier '/'
Store Procedures in PHPmyadmin
How to Save Memory When Reading a File in PHP
PHP Check Value Against Multiple Values with Or-Operator
Php, Simplexml, Decoding Entities in Cdata
Returning Multiple Rows with MySQLi and Arrays
How to Check the Performance of MySQL Indexing
Why Does This PHP Code Just Echo "Array"
How to Connect to MySQL Database in PHP Using MySQLi Extension
How to "Validate" Human Names in Cakephp
PHP File Upload, How to Restrict File Upload Type
Calculate Skip Value for Given Record for Sorted Paging
Sqlstate[42S22]: Column Not Found: 1054 Unknown Column - Laravel
A Conditional Element Inside an Array(...) Construct
Get Size of Post-Request in PHP