Edit php.ini File to include extension for mysqli - php

So, I'm trying to use a table in a php program and I got a fatal error (class mysqli not found) which after researching on stackoverflow means I don't have extension=php_mysqli.dll enabled (here's the php-website which talks about enabling it: http://php.net/manual/en/install.windows.extensions.php.)
But I looked in my php.ini file and the sort of ";extension=..." lines that it talks about commenting aren't there (I did ctrl + f to search through as well as manually searching through). I tried just adding the "extension=php_mysqli.dll" line but it still didn't work.
Someone else also said you need to uncomment the extension_dir line in php.ini and specify my location but that line only appears in an if loop in php.ini and it's not commented out. (from this stackoverflow question: Fatal error: Class 'MySQLi' not found).
How do I add "extension=php_mysqli.dll" to my php.ini file so my php program can create a mysqli table?

If you don't have mysqli extension in you php version you should download another version of PHP.
http://windows.php.net/download/
Get PHP 7 OR PHP 5.6 last version (thread safe recommended).
After, following the instructions on this page http://php.net/manual/en/install.windows.extensions.php to activate mysqli extension.
;extension=php_exif.dll
extension=php_mysqli.dll // Uncomment this line
;extension=php_oci8_12c.dll
You can define the path of your php extensions folder if you have problems.
To do this, uncomment line extension_dir.
extension_dir = "C:\php\ext" // Your ext folder path
Restart your apache / nginx and try to use mysqli functions.
Hope this will can help you.

In my case, I had the extension=mysqli set in my php.ini and the php_mysqli.dll file in the php/ext folder, I just had to uncomment (remove the ;) the extension_dir line in php.ini:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
;extension_dir = "./"
; On windows:
extension_dir = "ext"
Save php.ini and restart php and the webserver.

Related

How to enable sockets in php as mentioned in the manual?

I have Xampp installed and want to work with sockets in php, so I started with the sample code from http://php.net/manual/en/sockets.examples.php on localhost.
I got this well known error:
Fatal error: Call to undefined function socket_create() in
C:\xampp\htdocs\simpletcpipserver.php on line 14
After searching the web I changed the PHP.ini files:
I removed the ; from extension=php_sockets.dll and edited this part to:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = C:\xampp\php\ext
php_sockets.dll is present at that location.
But still I get the same error.
I did see this on http://php.net/manual/en/sockets.installation.php:
The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the --enable-sockets option to configure.
Apart from what I already did, I don't understand what this means.
Would should I do now to get the sample code to work?

PHP extensions not found via httpd but are found from CLI, with the same php.ini

I wanted to use some extensions of PHP 7.1 after installing it and Apache 2.4 and on my Windows 7. I wrote a small test script index.php to call some functions of the given extensions.
<?php
var_dump(mb_strlen('p'));
var_dump(mysqli_connect_error());
and uncommented the appropriate lines from the php.ini, like
...
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
...
and configured the extension_dir according to the windows-specific part of the php.ini
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"
extension_dir = "ext"
I restarted the Apache web server and fetched the http://localhost/index.php. I got the error messages:
Fatal error: Uncaught Error: Call to undefined function mb_strlen() in C:\Program Files\Apache24\htdocs...
which means the extension was not loaded.
I doublechecked that the php.ini I made the modifications in is the same as the phpinfo() displayed in the browser:
Loaded Configuration File C:\Program Files\php\php.ini
On the contrary, if I started the same index.php not via web server but from the command line then I got different output:
C:\Program Files\Apache24\htdocs>"C:\Program Files\php\php.exe" index.php
int(1)
NULL
which means the extensions were loaded properly.
The command line PHP uses the same php.ini:
c:\Program Files\Apache24\htdocs>php -i|find "Loaded Configuration File"
Loaded Configuration File => C:\Program Files\php\php.ini
How can it be that the same php.ini file loads the extensions from command line but does not load them when used via the web server?
Contrary to the description in the php.ini, the extension_dir should be specified with a full path, not just a relative one. Changing the line in php.ini from
extension_dir = "ext"
to
extension_dir = "C:/Progra~1/php/ext"
and restarting the web server solved the problem.
NB: I used the DOS-8.3 path instead of "C:/Program Files/php/ext" because according to the php-7.1.11-Win32-VC14-x64.zip\install.txt manual, it does not like paths containing spaces:
You may choose a different location but do not have spaces in the path (like C:\Program Files\PHP) as some web servers will crash if you do.
The path I referred to doesn't contain any spaces so I don't think I did anything wrong. Despite this, I am not sure how it would work if I had installed php to the default directory c:\php but it seems that defining the full path is a more secure way.
Check which modules is Apache using:
go to your apache config. IE: cd /etc/apache2/mods-enabled
list enables modulesls -lsai php* (in my case, prev version was enabled)
remove previous modules (IMC: rm php*)
enable needed module. IMC:
sudo ln -s ../mods-available/php7.4.load
sudo ln -s ../mods-available/php7.4.conf
reload apache (IMC: sudo /etc/init.d/apache2 restart)
use print/dump phpinfo(); to check which php module Apache is runnig
Command in example will work on Linux/Unix machines. Not on windows I'm afraid

edit on php.ini doesn't work

I have PHP in an Apache2.
When I do a modification in my php.ini, like uncomment a module to active it, it doesn't work.
In my phpinfo(), the Loaded Configuration File is on C:\php\php.ini, which is the right place.
I restart my Apache after every edition on the php.ini.
PHP run well on the Apache.
So why I can't active my module ? (Actually I'm trying to active the PDO driver for MySQL)
Uncomment this line to consider extensions :
; extension_dir = "ext"
extension_dir is the problem - make sure you have that pointing to the directory, where your DLL is.

How to enabling PDO_SQLITE in PHP Version 5.4.19 windows

I'm trying to enable PDO for SQLite3 on php 5.4.19. Following this--> http://www.php.net/manual/en/pdo.installation.php
uncommented the line in the php.ini file that says:
extension=php_pdo_sqlite.dll
;added next line
extension=pdo.so
However, the phpinfo() still says:
PDO
PDO drivers no value
I would think it would like the SQLite driver would be listed.
Trying to troubleshoot so I also tried adding this to the php.ini file.
extension=php_pdo.dll
However, there is no such file in the /ext folder and it says this is no longer needed in this version of php.
What step am I missing?
Edit-->
Ok figured this out and it wasn't obvious to any research I did.
First, absolute paths were required which isn't documented anywhere that I could find. Final settings are:
extension=C:\php\ext\pdo.so
extension=C:\php\ext\php_pdo_sqlite.dll
extension=C:\php\ext\php_sqlite3.dll
[sqlite3]
sqlite3.extension_dir = C:\sqlite
Uncommenting extension_dir = "ext" in php.ini worked for me:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"
'phpinfo()no longer showsPDO drivers : none enabled' and shows PDO drivers : sqlite instead.
It also now shows sections for SQLite3 and pdo_sqlite.
First, try restarting your web server. If that doesn't work, check if extension_dir is set properly in php.ini. If that still doesn't work, check if the proper php.ini is being read in the phpinfo() output.

PHP - PHP Warning: PHP Startup: in Unknown on line 0

I installed apache2 and php 5.4.5.
When you start apache this error:
PHP Warning: PHP Startup: in Unknown on line 0
The extension does not work:
; extension = php_intl.dll
; extension = php_ldap.dll
; extension = php_oci8.dll
; extension = php_oci8_11g.dll
; extension = php_pdo_firebird.dll
; extension = php_pdo_oci.dll
; extension = php_pdo_pgsql.dll
; extension = php_pgsql.dll
; extension = php_pspell.dll
; extension = php_shmop.dll
And maybe more.
Extensin dir: extension_dir = "C :/ dev/prog/php5/ext /"
Path: C: \ dev \ prog \ php5
php.ini is copied to C: \ WINDOWS \
ssleay32.dll php5ts.dll and is copied to C: \ WINDOWS \ system32 \
Please simple instructions.
upgrade those modules using pecl command
Also, Check extension_dir directive in php.ini
I had the same problem. The issue is, that these lines are by default in php.ini
; On windows:
; extension_dir = "ext"
I assumed, that only an uncomment of the second line and Apache restart solves this problem. But it isn't!
I had to type a full path to the ext folder, such as below:
extension_dir = "d:\php-5.4.32\ext"
After this action, and restart of the Apache web server, the problem was solved.
You should check you php.ini file to make sure the extension_dir is exactly set.
I had the same problem when i enable these five extensions:
extension=php_mbstring.dll
extension=php_exif.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_curl.dll
The number of warnings is the same as the extensions that enabled.
So i guess may be there is sth. wrong with the extension setting.
When i change the extension_dir directive to the right dir, the problem resolved.
I found this answer in this post on the wampserver forums, and it worked for me:
Click on the Apache version that you use in the WAMPServer menu, e.g.
wampmanager -> Apache -> Version -> 2.4.9 ( just click on the version number on this menu item )
this will rebuild the SYMLINKS for the extensions that are causing the "in Unknown on line 0" error.
The answer was given by RiggsFolly in this thread: http://forum.wampserver.com/read.php?2,128734
I had the same problem when I enabled extensions (see Error when enabling PHP extensions).
I resolved it adding the PHP folder to the path and restarting the computer.
You need to download and install Aspell for Windows “GNU Aspell-0.50.3 (win32)”.
http://aspell.net/win32/
http://ftp.gnu.org/gnu/aspell/w32/Aspel ... -Setup.exe
Your Dictionaries are also here. Aspell needs at least one Dictionary to operate.
or
ftp://ftp.gnu.org/gnu/aspell/w32/
ftp://ftp.gnu.org/gnu/aspell/w32/Aspell ... -Setup.exe
ftp://ftp.gnu.org/gnu/aspell/w32/aspell-w32-0.50.3.zip
Aspell should copy the “aspell-15.dll” to the “Windows/System32” directory which the php entension php_pspell.dll requires and looks for to execute.
If not then locate aspell-15.dll in C:/Program Files/Aspell/bin/aspell-15.dll and copy it to C:/Windows/System 32/aspell-15.dll
You only need now to uncomment this line in:
xampp/apache/bin/php.ini
;extension=php_pspell.dll
to this:
extension=php_pspell.dll
Restart Apache.
(If Apache won't start paste the error message here).
Check the pspell module is in place and enabled by lookin at your phpinfo() file from the menu within the XAMPP Welcome Page. http://localhost/index.php
For more info visit https://community.apachefriends.org/f/viewtopic.php?p=83942
The problem is not coming from there, the problem is from the path (I mean %PATH% for Windows users, because of %PATH% is a variable that contains many paths separated by ;). So to figure out the problem you have to:
1-make configuration in the httpd.conf file:
PHPIniDir "${path}/conf_files"
2-make configuration in your php.ini file (it must be in the same location with the httpd.conf file):
change this:
extension_dir = "${path}\php\ext\"
To
extension_dir = "D:\EasyPHP5.3.0\php\ext\"
(in my case the php is installed in D:\EasyPHP5.3.0)
Optional:
if you need to execute PHP from the CLI (Command Prompt)
you have to make copy of the php.ini file to the folder when the PHP is installed (in my case D:\EasyPHP5.3.0\php)
Restart/Start your web Server and enjoy!
I had similar problem. cURL required SSL layer. Problem was in installation of php_curl library, see http://php.net/manual/en/curl.installation.php. The firs problem: libeay32.dll and ssleay32.dll are required on PATH. I put them in apache/bin directory. The second problem is that php.ini required php_openssl loaded before php_curl so I modified ini file.
extension=php_openssl.dll
extension=php_curl.dll
I solved the problem on my windows 7 with two steps:
set extension_dir as absolute path in php.ini
extension_dir = "d:\php-5.4.32\ext"
comment the php_curl.dll module in php.ini
;extension=php_curl.dll
Same problem was solved by changing to full path:
PHPIniDir in httpd.conf and extension_dir in php.ini.

Categories