Problem with PHP/Java bridge - php

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.

Related

Win10/Apache/PHP8: PHP cannot load pgql library [duplicate]

I'm installing PHP, Apache and PostgreSQL Manually
PHP and Apache now is connected, but PostgreSQL is not connected to PHP.
i test by using phpinfo();
i also configure in php.ini like this :
extension=php_pgsql.dll
extension=php_pdo_pgsql.dll
But why it's not work.
Thanks
This tutorial worked for me:
The PHP extension will look for libpq.dll which is found of your
PostgreSQL installation. The simple fix is to add the path than
contains that file to your environment PATH.
I had the same issue with PHP7 and Apache 2.4 on Windows 10. For me the solution was to add the following line to httpd.conf;
LoadFile "C:/php7/libpq.dll"
This also means that it's not required to have PostgreSQL installed if you just want to connect a PostgreSQL database that's not running on your machine.
1) Installing PostgreSQL for Windows
2) add to your enviroment variable "PATH" the bin folder of PostgreSQL installation:
C:\Program Files\PostgreSQL\9.2\bin; (for example)
Assuming you have installed PostgreSQL and your WAMP installation is on c:\wamp, you will need to copy
c:\wamp\bin\php\php5.3.9\libpq.dll to c:\wamp\bin\apache\Apache2.2.11\bin
Make sure you also have the following files
C:\wamp\bin\php\php5.3.9\ext\php_pdo_pgsql.dll and
C:\wamp\bin\php\php5.3.9\ext\php_pgsql.dll
Also, make sure you have enabled the above 2 files as extensions, either via the WAMP menu (click on WAMP icon on taskbar, PHP, PHPExtensions, find the above 2 and 'check' them)
Please note that php5.3.9 and Apache2.2.11 refer to my specific PHP and Apache versions.
Adjust those to suit your installation.
That's it!
This worked for me on Windows:
Found php.ini in php folder.
Found this line and removed “;”.
;extension=php_pgsql.dll
in my case there are 2 php.ini, I had to uncomment extension pdo_pgsql in both php.ini
in php folder
in apache folder
both inside in wamp folder
If you are using PHP in IIS, using PHP Manager, enable this extension:
php_pgsql.dll

ERROR: You must have the pdo_sqlite PHP extension installed (Windows) Drupal CMS

I am trying out the Drupal CMS, and I wanna try it out on my local computer first so I am following this guide: https://www.drupal.org/docs/official_docs/en/_evaluator_guide.html. Drupal requires PHP to run.
I installed php 8.0.3 for Windows Zip and put it in my path file so PHP works on the command prompt.
I also installed Drupal 9.1.5 unzipped it and am currently running commands in the drupal-9.1.5 directory.
I ran the command from this set up guide thinking it would launch drupal:
php core/scripts/drupal quick-start demo_umami
And the command prompt gave me the error:
[ERROR] You must have the pdo_sqlite PHP extension installed See
core/INSTALL.sqlite.txt for instructions, now I checked
so I headed over to INSTALL.sqlite.txt in the Drupal directory and it told me:
Windows
------- Read more about it on http://www.php.net/manual/en/pdo.installation.php
I went to the website and it says that the driver is enabled by default, but since I'm getting the error, it must mean I don't have it on PHP so it told me to head over to the php.ini file. In my PHP directory, since it's a newer version it has the php.ini-development file and php.ini-production file.
The windows fix says to simply uncomment ;extension=pdo_sqlite to extension=pdo_sqlite which I did for both php.ini-development and -production files. This is where I'm stuck. I did exactly what the error told me to fix and I am still getting it. How can I fix this?
I looked around and every solution for windows is to uncomment and I still get the error.
Another thing on the php manual states that extension=php_pdo.dll, but my php.ini file does not have the extensions. does that matter?
Here are my uncommented extensions which I thought could contribute to helping the error:
extension=php_pdo.dll
extension=pdo_sqlite
extension=sqlite3
One last attempt at trying to get this php command to work is installing the Windows sqlite binary and putting it into windows path (contains a dll not an exe), but that didn't help anything either.
How do I fix this. Thank you.
Hi just make a copy of "php.ini-development" and rename it "php.ini".
And uncomment the extensions you need.

PHP ldap_connect() problems

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!

mysql is not enabled in phpinfo() of php 5.3.1

I am having apache 2.2.14, php 5.3.1 and mysql 5.1.43 installed on vista. I am trying since 2 days to configure php to have mysql enable on phpinfo().
I modified php.ini to have extension_dir = "c:\php\ext"
modified the extension as extension="php_mysql.dll"
added "c:\php" to the "PATH" environment variable and restarted the vista.
after trying many combinations of putting php.ini, php_mysql.dll and libmysql.dll in c drive and/or c:/windows and/or c:/windows/system32 now I am with no options!!
I do restart the apache after each modification. I used libmysql.dll present in mysql installation and that of older php version as php 5.3.1 has no libmysql.dll...
Any help will be appreciated.
Thanks in advance.
You have to edit php.ini and add/uncomment a line to import the php_mysql.dll extention. Search for ;extention=php_mysql.dll and remove the ;. If you find this line without the ; in front of it, you have another problem. If you don't find this line, add it without the ;.
You can also try to put a \ after the extention path: extension_dir="c:\php\ext\"
put php_mysql.dll in the "c:\php\ext" directory (and keep the extension="php_mysql.dll" uncommented [without the leading ;])
Make sure you've edited the right php.ini. In case of doubt
<?php echo 'ini= "', get_cfg_var('cfg_file_path'), '"';
will tell you which one is used by your php installation.
Maybe php tried to load the php-mysql extension and failed because of additional dependencies. That would cause a startup error entry in the error.log.
Which php-build do you use? The php-mysql extension can either use libmysql.dll as transport layer or the new mysqlnd (MySQL native driver) module. You've added c:\php to PATH. That's usually done in order to let windows find libmysql.dll (though it's not necessary, there are other methods which I prefer). If php-mysql depends on libmysql.dll and windows can't find it loading php_mysql.dll will fail.
But if you're using the php.net build of php 5.3.1 the mysql module uses mysqlnd:
Installation on Windows
In the official PHP distributions from 5.3 onwards, MySQL Native Driver is enabled by defaultThis module is built-in in the php.net build. You can test that by calling php -m in a command shell. It prints all built-in modules.
Thanks a lot to the user who said that we have to move the file php.ini to the folder /bin of the Apache server. it resolves me the same problem after more than one week of trying failed methods.
Of course we must uncomment in the file the two lines;
;extension=php_mysql.dll
;extensin_dir="ext"
by removing the semi-colon (;) and by specifying the full path for the extension library php_mysql.dll rather than ext as follows
extension=php_mysql.dll
extensin_dir="c:\Apache22\php53\ext"
For me I installed Apache in the folder c:\Apache22 and PHP in the folder c:\Apache22\php53, you must use your own values.
NOTE: Because mysql_ functions like mysql_connect() become deprecated in PHP 5.5 and above, it is recommended to enable also the library php_mysqli.dll to use functions like mysqli_ (improved version of mysql_ functions). To do that it is simple, you just have to uncomment the line:
;extension=php_mysqli.dll
in the file PHP.ini as follows:
extension=php_mysqli.dll
Update April 7, 2013. Installed Windows 8 on an i7 Quad, HT 8, 3.62GHz, 12GBRAM.. Installed the latest version of MySQL, got it functioning properly. Installed the latest version of Apache Web Server, got it functioning properly. Installed the latest version of PHP, got it functioning properly. MySQL could not connect to the database. The error message was "mysql_connect function undefined". I copied the modified php.ini file into the "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin", and restarted Apache web server... then it all magically started working.!!! I hope this helps somebody with setting up their own Windows MySQL / PHP web server.

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