PHP ldap_connect() problems - php

I am trying to get ldap_connect to work properly. It will work fine via CLI, but not when I open my php file via browser.
Here is what I believe are the relevant details:
Error message: Fatal error: Call to undefined function ldap_connect() in F:\Websites\ldap.php on line 4
OS: Windows Server 2008 R2 x64
PHP Directory: C:\Program Files (x86)\PHP
libeay32.dll and ssleay32.dll have been added to both C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin and C:\Windows\System32. They were copied from C:\Program Files (x86)\PHP.
Lines added to httpd.conf:
LoadModule php5_module "C:/Program Files (x86)/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/Program Files (x86)/PHP"
Things changed in php.ini:
extension_dir = "C:/Program Files (x86)/PHP/ext" (path set)
extension=php_ldap.dll (uncommented this line)
I'm pulling my hair out, so I am more than happy to try anything people suggest.

Your PHP installation uses two different ini files - one when running from the command line, and a different one when running through Apache. This is evidenced by the fact that it works from the CLI, but not in a browser.
You can find the paths to the two files using phpinfo() (in a browser) and by passing the -i flag to php from the command line. Near the top of both sets of output you will find the path to the ini file in use, and I would be mighty surprised if they were identical. From the command line you can get more detailed information by passing the --ini flag.
The fact that you are getting Call to undefined function ldap_connect() can only mean that the LDAP extension was not loaded, and this can only be true through Apache but not through the CLI if they use two different ini files.

I feel silly now. The problem was with adding my PHP directory to the PATH environment variable. I'm not 100% sure why it fixed the problem, but that was what ended up doing it. Thanks for the help, guys!

Related

Call to undefined function Illuminate\Encryption\openssl_decrypt()

I am using xampp and windows along with laravel, everything was working fine, but when I finished work and turned of xampp and try to open my work today morning, this is what I get:
FatalThrowableError in Encrypter.php line 100:
Fatal error: Call to undefined function Illuminate\Encryption\openssl_decrypt()
Encrypter.php is a standard laravel file and I have not even touched it. My extension is turned on.
extension=php_openssl.dll
What might be wrong?
Just edit php.ini file and uncomment by removing ";" before this line --extension=openssl. in php.ini file. and it will start working properly.
If you have shut XAMPP down and restarted it, it may be worth running the composer install command again, or simply running composer update to ensure that all dependancies are being loaded correctly.
Modify php.ini and enable openssl extension in you php environment.
To find php installation path, run below command in terminal or cmd
php --ini
Output something like below:
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\php-7.3.8\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
here mine is
Loaded Configuration File is C:\php-7.3.8\php.ini
open php.ini with any editor using vim, nano, notepad++ or any editor.
find extension=openssl remove ;
from ;extension=openssl
to extension=openssl
save and restart server.
composer install
didn't fix the problem, but the following does:
composer update
This problem can also arise if incorrect php.ini file is loaded.
Make sure in your config php_module is defined in the httpd.conf
<IfModule php_module>
PHPINIDir "C:/xampp/php"
</IfModule>

Enabling cURL with PHP

(I'm running Apache 2.2 and PHP 5.4.14)
I'm having problems enabling cURL with PHP. I uncommented the extension=php_curl.dll line in php.ini and made sure that the dependencies libeay32.dll and ssleay32.dll exist in the path. I also restarted Apache. However, when I run phpinfo() I do not see a cURL header and trying to call a cURL function results in the following error:
Fatal error: Call to undefined function curl_init() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\boxproject\php\lib\Box_Rest_Client.php on line 114
Does anyone see any problems with this process? Are there more ways to troubleshoot the problem? Thanks a lot for the help.
Step1: Uncomment the php_curl.dll from php.ini
Step2: Copy the following three files from php installed directory to the bin directory of Apache
libeay32.dll, libssh2.dll, ssleay32.dll
Step3: Restart apache.

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

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.

Problem with PHP/Java bridge

I am using Tomcat 6. I am running a php script using the JavaBridge. I get the following error when I run my code.
Fatal error: Call to undefined function mysqli_connect() in C:\Program Files\apache-tomcat-6.0.26\webapps\JavaBridge\xxxx\xxxxx.php on line 534
Please help.
I'm not really sure what I've done but mine is working as I read the documentation. in my case it's MySQL and I am using Tomcat 7.
copy the correct VERSION of the PHP extension "php_mysql.dll" to the correspond "ext" directory, in my case it's in "C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\aeu\WEB-INF\cgi\amd64-windows\ext"
uncomment/add this line,
extension = php_mysql.dll
in php.ini and mysql.ini file, in my case there're as C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\aeu\WEB-INF\cgi\amd64-windows\php.ini and C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\aeu\WEB-INF\cgi\amd64-windows\conf.d\mysql.ini
and lastly restart Tomcat. good luck.
I would do two things:
Make sure that location of
php_mysql.dll is included in the
PATH env variable.
Open your php.ini file, and look
under the extensions. Make sure that
the line for loading php_mysql.dll
is not commented (make sure there
isn't a ; in front of it).
Probably due to some missing libmysql.dll, try to look for this file (windows find could help) and make sure it sit's on a directory belonging to you PATH. (see this topic)
You may need to configure PHP with the option: --with-mysql = path_to_mysql
I would just like to highlight Bruces question here relates to using the mysqli API (not the older mysql API)
Managed to get this working. HAD TO USE mysqli.ini INSTEAD OF mysql.ini in my case:
- Apache-Tomcat-9.0.10
- PHP Version 5.6.38
- JavaBridgeTemplate721.war
- MySql 8.0.12
...first had to copy php5ts.dll and php-cgi.exe to setup the PHP enabled Tomcat project to the:
\WEB-INF\cgi\x86-windows\
and then copy php_mysqli.dll and setup the mysqli.ini to enable the mysqli.

PHP not loading php_pgsql.dll on Windows

PHP 5.2.8 is refusing to load php_pgsql.dll, with the following error:
Warning: PHP Startup: Unable to load dynamic library 'D:\PHP\ext\php_pgsql.dll' - The specified module could not be found.
in Unknown on line 0
The .dll exists in PHP/ext/.
Has anyone else had this problem with PHP on Windows before?
Check out the info on the PHP PostgreSQL installation page: http://us.php.net/manual/en/pgsql.installation.php
On a Windows server, configured with Apache, adding the following line to httpd.conf to load libpq.dll can save you a lot of time :
LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.dll"
Note that you will have to change your folder accordingly to the installation path and version of PostgreSQL you have installed. Also note that having Apache and PostgreSQL on the same server for production environments is not recommended.
This fixed my setup instantly.
This happened to me also with PHP 5.4.1
Copying the offending DLL everywhere didn't work, and I don't have PostgreSQL installed in the server, but I also planned to use PHP against different Postgres versions, so the only solution I found that worked was to put in httpd.conf a line like this:
LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.dll"
And referring to the libpq.dll that comes bundled with PHP, like this:
LoadFile "C:/php/libpq.dll"
After that it worked fine to me.
For those willing to make their PHP install only capable to access PostGres servers, without actually installing PostGres, you need to:
enable php_pgsql.dll (and php_pdo_pgsql.dll, if using PDO) extension in PHP.INI,
make sure libpq.dll, libiconv-2.dll and libintl-8.dll are in the path. These are the php_pgsql.dll dependencies.
These 3 DLLs can be found in the PostGres install. I just copied them into apache\bin, that way I keep everything self contained. Doing that, apache can start the PHP engine just fine, with PostGres support.
The problem is with the related libraries used by php_pgsql.dll - like libpq.dll, the OpenSLL ones etc. You need to find them (from the zip distribution of Postgres, from an installed psqlODBC driver etc.) and put them in a folder which is in the PATH. As for the list of all DLLs - use MS Dependency Walker (depends.exe).
Another important bit - Apache (if you use Apache that is) has its own set of OpenSSL DLLs. Replace or just rename those so to not clash with those from the Postgres distribution.
You need to copy libpq.dll from wamp\bin\php\php5.3.5 to wamp\bin\apache\Apache2.2.17\bin. Again restart the Wamp Server. By now we are done with the php configuration. Next we will install phpPgAdmin and use it.
Just a thought -- make sure that the Postgres binaries are in the SYSTEM path, not your user-specific path. As it happens, that was the problem on my machine. :-)
Edit:
Come to think of it, that explains why Dependency Walker would report all A-OK but the problem would still persist -- you run DW under your own account, while Apache runs as SYSTEM, and hence won't have your personal PATH settings available.
Just to share what worked for me, without dealing with libpq.dll. I uncommented both extension=php_pdo_pgsql.dll and extension=php_pgsql.dll in php.ini. At first, apache refused to start.
I then add "C:\Program Files (x86)\PostgreSQL\9.4\bin\" (depending on your installation) into windows environment PATH, started apache successfully and works.
Specifically for WAMP server setups here, you need to copy the libpg.dll file into "C:\wamp\bin\apache\Apache2.2.21\bin\", or similar. Copying it to ..\php\ext\ and also adjusting the PATH env variable simply wasn't enough (if effective at all).
Original answer sourced here: http://www.wampserver.com/phorum/read.php?2,40270,57932
Specifically for XAMPP setups, I found that I only needed to copy the libpg.dll file into ..\php\ext\ directory.
As Ondřej Bouda mentioned: Setting up Windows environment variables is enough. No copies of dlls, no entries to http-conf. Just add the php-directory (C:\xampp\php) to PATH. Don't forget to restart XAMPP-Control-Panel if you use this, otherwise it won't know the changes. (And restart Apache of cause.)
For instance, on XAMPP, it was sufficient to put the PHP directory
(i.e., C:\xampp\php) to the system PATH variable. – Ondřej Bouda
This is an update to #Dayron Armas Peña 's answer. The php bundled pgsql 'dll' is found in the following location:
LoadFile "C:/wamp/bin/php/php5.4.12/libpq.dll"
Adding the above line to the httpd.conf file apart from uncommenting the required lines in the php.ini files has solved my problem.
The only time I've seen this error (and the file name and ext path were definitely correct) was when I tried using an incorrect version of the DLL ie. I used one that was compiled against a different version of PHP to the one I was running.
Make sure your version is definitely the one compiled against PHP 5.2.8.
Edit: or, the permissions on the file were set incorrectly.
LIBPQ.DLL problem with php on Vista...
Check to make sure you actually have postgres installed. If you install php on windows with postgres API, without postgres being installed, you may get this warning. It's too easy to just click everything on the Windows installer...
Comment out the relevant line in php.ini.
I got the solution:
1) If you want to load php_pdo_pgsql extension, please load php_pdo, too. (in php.ini)
2) php_pgsql.dll and php_pdo_pgsql.dll depend on libpq.dll and php5ts.dll. libpg.dll is the library from postgreSQL, but it has been bundled into PHP's binary package.
When configuring PHP to work as a module with Apache, it can't load the depending library correctly. And so you need to load it in Apache.
config in httpd.conf and the two lines should be before LoadModule php5_module
LoadFile "Full path to /php5gs.dll"
LoadFile "full path to libpg.dll"
Hope it be helpful.
You have to add the following lines to you httpd.conf file:
PHPIniDir "c:/PHP/"
Loadfile "C:\php\php5ts.dll"
Loadfile "C:\php\libpq.dll"
LoadModule php5_module "c:/PHP/php5apache2_2.dll"
Source: http://www.php.net/manual/en/pgsql.setup.php
I just did this and it worked just fine
in php folder inside php.ini I changed this line
extension=php_openssl.dll
to
extension=C:\php\ext\php_openssl.dll
the php_openssl.dll is inside ext folder which couldn't be found.
Copy file libpq.dll from location /bin/php/ to
location /bin/apache//bin. Restart the wamp server.
I found this to work for me:
After installation of PostgreSQL, you need to copy libpq.dll from wamp\bin\php\phpX.X.X to wamp\bin\apache\Apache2.2*\bin. And restart the Wampserver.

Categories