Windows, NetBeans: Where's the php.ini? - php

I have been away from PHP for quite a while, so hopefully this is a simple oversight. But, I am not able to include the MySQL extension.
Setup
Windows 8 Pro 64-bit
NetBeans 7.2.1 (Built-in PHP Web Server)
MySQL
PHP 5.4.8
Problem
Fatal error: Call to undefined function mysql_connect()
Attempted Resolution
Copy php.ini-development to php.ini (files are where I installed PHP, E:\Software\php-5.4.8-Win32-VC9-x86)
Edit php.ini by uncommenting the lines
extension_dir = "ext"
extension=php_mysqli.dll
Added E:\Software\php-5.4.8-Win32-VC9-x86\ext to NetBeans PHP Include Path in Project Properties
Still fails with the same error
Diagnostic Output
Added a call to phpinfo() at the top of the page. That indicates:
Configuration File (php.ini) Path C:\Windows
However, there is no php.ini in C:\Windows. In fact, I searched all disks and found only the one php.ini file that I previously edited.
Question
Where is NetBeans / PHP pulling the configuration from when I run my project, and how can I edit that configuration?

Restart the web server/netbeans :-)

If there's no php.ini file listed as being loaded by phpinfo() then there is not one. PHP will use default values for everything in this case. Anything that needs to be overridden can be placed in a new php.ini in one of the locations specified by phpinfo() as being scanned for ini files.

From your description what you did to php.ini (excerpt):
extension=php_mysqli.dll
^
But in your question you write:
Fatal error: Call to undefined function mysql_connect()
Which is a different extension, namely on windows:
extension=php_mysql.dll
(without the i)
Probably it's just a little oversight you're missing here. You have two options then:
Port the code to mysqli_* functions (recommended for new code)
Activate the old php_mysql.dll extension (for legacy code)
Do what fit's your needs. On windows, the folloing filenames (search your disk) are interesting:
php.ini - normally inside the directory where you find php.exe
php_mysql.dll - normally inside the ext subdirectory of the just said directory.

Related

What is the default path for PHP extensions in php.ini?

I'm getting back in to web development so have decided to re-install my Mac's dev environment from scratch with homebrew (I'm following the tutorial at https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions which is probably the best tutorial on the subject that I've ever read).
Everything is going fine apart from using PECL to install extensions like APCU and Xdebug. I think I can get extensions working in a slightly hacky way, but I'd rather properly understand what's going on here.
My php.ini file is located at /usr/local/etc/php/7.1/php.ini. When PECL installs an extension, it seems to add a line to the top of php.ini immediately above the [PHP] line, e.g.:
1 zend_extension="xdebug.so"
2 extension="apcu.so"
3 [PHP]
4
5 ;;;;;;;;;;;;;;;;;;;
6 ; About php.ini ;
7 ;;;;;;;;;;;;;;;;;;;
8 ; PHP's initialization file, generally called php.ini, is responsible for
9 ; configuring many of the aspects of PHP's behavior.
The tutorial advises going to /usr/local/etc/php/7.1/conf.d/ and creating individual config files for each extension. i.e., lines 1 and 2 in php.ini would be deleted, and /usr/local/etc/php/7.1/conf.d/ext-apcu.ini and /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini would be created, with config settings for each extension included in the relevant ext-xx.ini file.
Neither the default PECL approach of referencing the extension in php.ini nor the recommended approach of using an ext-xx.ini file for each extension seems to load the extensions successfully. I can hack round this by specifying a path to the extensions (/usr/local/lib/php/pecl/somedatestamp/extension.so), but I'd rather not have to. So:
(I'm pretty sure the answer to this is "yes", but just to be sure): does the server just scan through the conf.d folder and try to load any extension.so that is described in every ext-extension.so file it finds?
How do I set the equivalent of $PATH for my PHP configuration? phpinfo() refers to an extension_dir variable and gives the value as /usr/local/Cellar/php#7.1/7.1.20/lib/php/20160303, and there's an extension_dir variable set in php.ini but it's commented out. So where is PHP getting the value it's displaying through phpinfo(), and is it possible to specify multiple directories where PHP will look for extensions?
Server doesn't scan for *.so files automatically, it loads extensions mentioned in php config files in extension=extension.so and zend_extension=extension.so configurations. To check all config files which are loaded during server start run the command php --ini, my example output is:
$ php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.1
Loaded Configuration File: /usr/local/etc/php/7.1/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.1/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.1/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.1/conf.d/ext-phalcon.ini,
/usr/local/etc/php/7.1/conf.d/ext-xdebug.ini,
/usr/local/etc/php/7.1/conf.d/php-memory-limits.ini
In you case it looks like you might have messed versions: your config file is located in /usr/local/etc/php/7.1/php.ini (version 7.1) but you are trying to put additional config files in /usr/local/etc/php/5.6/conf.d/ (version 5.6). Try to put them in /usr/local/etc/php/7.1/conf.d
You should specify extension dir path in your php.ini, I have the value
extension_dir = "/usr/local/lib/php/pecl/20160303"
This value is valid for php version 7.1, timestamp 20160303 specifies PHP API version for the extensions.
You can also check that PECL configuration for the extension dir has the same value as in php config using the command
pecl config-get ext_dir
After these steps you can check if extension is loaded with the command
php -m
It lists all the loaded php modules and extensions. If some extension is mentioned in config file but could not be loaded, you will get warning.

cURL is enabled in php.ini but still not working

I have enabled the cURL extention in he php.ini folder, I have copied mutliple dll files from the PHP folder into the Apache Bin folder and the System 32 folder but cURL is still not enabled on my system.
All the solutions that I have looked at:
How to enable cURL in PHP / XAMPP
http://php.net/manual/en/curl.installation.php
http://php.net/manual/en/curl.installation.php#115953
http://php.net/manual/en/curl.installation.php#117372
I know this because I still see the following error:
Fatal error: Call to undefined function curl_init() in C:\AMP\sites\ftp-crawl\index.php on line 55
When I run only phpinfo(), there are no cUrl options. The only mention of cURL is under module authors and its value is cURL: Sterling Hughes
I am running a windows 10 developer machine with PHP, MySQL and Apache installed.
What do I still need to do or check to enable curl?
I had the same problem. I fix it replacing the php_curl.dll. Maybe a file corruption.
In php.ini I setup with extension=php_curl.dll.
No more Call to undefined function curl_init() errors.
I resolved the issue by editing my PHP.ini to include the full path of the extension as opposed to just the name.
So where most php.ini files just have this line of code:
extension=php_curl.dll
I changed it to look like this:
extension=C:\amp\PHP\ext\php_curl.dll
I have no idea why PHP/Apache couldn't show an error while I had extension=php_curl.dll in my php.ini. At least saying something like dll missing or something like that, but that resolved my issue.
I believe you edited the demo or wrong php.ini file.
In your phpinfo you will find a path to the used php.ini file. It's next to the text: "Configuration File". Check out that file and make sure that the following option is set (by default it is commented out with a semicolon).
extension=php_curl.dll
If you can not find this line, you might have a different version of Apache. In this case you might find a directory called "mods-available" in which the curl extension lays. You need to move this file to the "mods-enabled" folder. Honestly I think this only applies to Linux environments, not sure about Windows.
It means that the curl module is not installed on the server. This problem generally occurs with php5. You need to check if php5-curl module is installed or not. Also confirm if curl is installed on the system.
Terminal command curl -v.

Can't find php.ini file 5.4.19 version in Windows 2003 server install

We have php 5.4.19 installed. PHP is installed in c:\php. There is a php.ini-development file and a php.ini-production file there. However, there is no php.ini file there. If I run phpinfo() it says:
Configuration File (php.ini) Path C:\WINDOWS
However, I don't see a php.ini file in c:\windows either.
Where the heck is the php.ini file. I know I have found this file before and modified it and I remember it being difficult to find. However, I can't for the life of me find it now.
Oh, the Microsoft search CANNOT find a file named php.ini either.
I tried installing the voidtools and it doesn't find a file named php.ini either.
I tried changing php.ini-production but it doesn't seem to have an effect.
The configuration path isn't important. The next line down should tell you what the loaded configuration file is. I suspect it says "none".
It's possible to run PHP without a configuration file. I don't recommend it. Create a php.ini. After installing PHP, you're supposed to copy either the development or production file to php.ini in the same path, and modify from there.
maybe you dont have file on path c:/php/php.ini and then php try load in windows diretcory maybe you can try create file on c:/php/php.ini if not exists.
P.S sorry for my english

PDO Exception "Could not find driver" (pgsql)

I downloaded and installed PostgreSQL 9.2.3, which came with Stackbuilder.
I used the PostgreSQL Stackbuilder to install Apache (2.2.22) & PHP (5.4.5).
Now I'm trying to connect to a database with PDO, but I'm getting a driver not found error.
I've un-commented the extension=php_pgsql.dll & extension=php_pdo_pgsql.dll in my php.ini file.
My phpinfo(); function shows that they're enabled.
The main thing I'm noticing is that within my php\ directory there's no ext\ directory with these files. I would have assumed that these files would have been automatically installed to a php\ subdirectory.
Where could these extensions be stored; do I need to designate an absolute path for php to find them?
UPDATE:
So I went into php.ini and turned on Startup Errors. When I launch the commandline php.exe I get errors stating that php_pgsql.dll & php_pdo_pgsql.dll can't be found.
It looks like they're trying to reference them on a D: drive, which I don't have. I installed everything to the same directory on the E: drive. I can't find the extensions anywhere (and neither can php).
In Wamp (windows)...
copy C:\wamp\bin\php\php5.x.xx\libpq.dll
paste in C:\Windows\System32\
on Wamp, there are 2 php.ini files, you will have to check if the Postgresql extension is on both!
The extension line is
extension=php_pdo_pgsql.dll
So check on
C:\wamp\bin\apache\apache2.4.9\bin\php.ini
Also check on
C:\wamp\apache\apache2.4.9\bin\php.ini
After adding the extension line, restart Apache and it will work.

Call to undefined function curl_init() error in wamp 2.2

I am having below error when I try to implement google and facebook authentication in windows 7 using wamp server.
Fatal error: Call to undefined function curl_init() in
E:\wamp\www\mysite\protected\extensions\eauth\EAuthServiceBase.php
on line 273
I am using,
wampserver 2.2
php version 5.3.13
I have enabled php_curl module as well. I checked in php.ini for confirm and it is uncommented as below.
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_dba.dll
The code has worked in ubuntu with xampp, but not in wamp in windows. I have done everything I can find. I have tried replacing the php_curl.dll also according to the comment on this thread, Call to undefined function curl_init() - with WAMP
My phpinfo() looks like below.
I have installed wamp in the partition E:\, but the "Configuration File (php.ini) Path" seems different, it is C:\Windows.
Please help me to fix the issue.
Visit this and have a file under Fixed curl extensions:
http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/
after download and replace related file then restart server.
In browser navigate to localhost and make sure there is curl extensions showing under Loaded Extensions :
For WAMP running PHP 5.4.3 on Windows 7 64 bit, make sure you use php_curl-5.4.3-VC9-x64.zip NOT php_curl-5.4.3-nts-VC9-x64.zip.
In windows 7 with PHP 5.5.31 after check that php_curl.dll extension is enabled (and still doesnt working), work for me to copy libeay32.dll and libssh2.dll from php directory to Apache bin.
just a guess - this section in php.ini does not reference the correct location
; Directory in which the loadable extensions (modules) reside.
extension_dir = *some value*
http://www.php.net/manual/en/ini.core.php#ini.extension-dir
edit
Also, look for this block in your phpinfo, if it's not there, curl isn't loading (obviously). You're not looking for matching version numbers - just for the block's existence.
edit
look at this question also
PHP and CURL under Windows 7 64 bits and Apache
When using WAMP..
You should have one file php.ini in the main PHP directory
In the php.ini enable the extension extension=php_curl.dll, by removing the ; char
The extension_dir must look like this example: extension_dir = "D:\AMP\PHP\ext\", so not a relative path
You need to restart Apache server only once. No need to restart it many times
Just make sure, you have the php_curl.dll in the ext directory
(windows 10 user)
Since this is the first result in Google and I had exactly the same problem and none of your solutions worked for me and I finally find the correct solution in an other thread of stackoverflow, I'll post link here :
EasyPHP Devserver 16.1 Curl Win 10
The solution is to add the your current PHP directory (depend of which version you use) to your global "path" variable in windows (like explained in the link, but you don't need to add all php directorias of course)
Not sure where to put my experience, hope it will be useful for someone.
In my case (win7 x64 + apache 2.4 + php 7.2), curl extension was enabled in php.ini but did not load. Resolved by replacing libs libssl-1_1-x64.dll and libcrypto-1_1-x64.dll in Apache's bin folder with the latest builds of OpenSSL
For those running PHP 7+ on windows, there is no php.ini file in the php directory by default.
You need to:
create a php.ini file in your PHP directory (it should be under C:\php\, or wherever your php directory is located)
Copy the content of either php.ini-development or php.ini-production into the php.ini file you've created.
Finally remove the semicolon (;) before extension=curl
Change the extention in php.ini file uncomment by removing ; like below
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_dba.dll
Then restart all services and it will work.

Categories