I'm trying to connect to my LDAP server via PHP, but I get the following error:
Fatal error: Call to undefined function ldap_connect()
Any help would be very appreciated.
Thanks in advance,
roshan
Make sure the LDAP extension is installed and enabled. This answer assumes you have PHP5, however, things should work similarly for PHP7 as well.
Install LDAP Extension
There should be a package named like php5-ldap:
aptitude show php5-ldap
Paquet : php5-ldap
...
Description : LDAP module for php5
This package provides a module for LDAP functions in PHP scripts.
Thus, the package can usually be installed like:
sudo apt-get install php5-ldap
If you do not use apt-get, use the equivalent command for the package manager you use.
Enable LDAP Extension
To enable the package after installation, you can use this command:
sudo php5enmod ldap
If you get any error message from the above command, it means something went wrong.
Note: After enabling the package, you usually have to restart / reload services so that the newly enabled module is recognized. For apache, you can do this by:
sudo service apache2 restart
If you do not use apache, please use the equivalent command for your server.
sudo apt-get install php5-ldap
And don't afraid to google.
Related
I added Paypal Express checkout plugin to my website.
I get this error:
2019-07-23T15:45:32+00:00 CRITICAL Uncaught Error: Call to undefined
function PayPal\Core\curl_version() in
/var/www/html/wp-content/plugins/woo-paypal-express-checkout/includes/php-library/paypal-rest/lib/PayPal/Core/PayPalHttpConfig.php:65
and this is the line
$curl = curl_version();
What can I do to resolve this probleme
I tried to install php-curl but I always got the same result
I used
sudo apt-get install php5-curl
sudo service apache2 restart
It sounds like you are missing the PHP CURL extension. This is usually bundled as a separate package. If you are using Ubuntu, apt-get install php-curl (or php7.2-curl) will install the missing dependency. You may need to enable the module after installing it using phpenmod curl. If you are using another Linux distribution, please consult the appropriate distribution documentation for installing PHP modules.
First, check your active PHP version, maybe there are multiple PHP versions installed on the server. In that case, you have to look for an active PHP version running on the server. Use phpinfo(); to check PHP version. Then run the command as per your PHP version. In my case, it was PHP 7.3.
$ sudo apt-get install php7.3-curl
$ sudo service apache2 restart
I'm trying to connect to Mongolab db server, but I get this error:
Fatal error: Class 'MongoClient' not found in /home/viviane/public_html/sk/zizi/head.php on line 33
I suspect it is related to the PHP Mongo Driver, but I don't know how. If I try to connect to a remote mongodb server
$uri = "mongodb://dzyasser:dzyasser#ds049624.mongolab.com:49624/serverdb";
$options = array("connectTimeoutMS" => 30000);
$connection = new MongoClient($uri, $options );
So why am I still getting this error when I'm trying to connect to a remote Mongodb server (Mongolab)?
Its look like you don't have MongoDB PHP extension in your system.
Try to install MongoDB PHP extension in order to solve your problems with the MongoClient class. This is how I setup MongoDB PHP extension in OS X.
Get MongoDB extension from PECL
$ sudo pecl install mongodb
Make a copy of php.ini.default
$ sudo cp /etc/php.ini.default /etc/php.ini
Put this line on php.ini than save
extension=mongodb.so
Check the installation using this command
php --re mongodb
Or create simple php document that contain phpinfo() function
If you get problem with writing the extension, please read this post.
I assume, the Mongo driver is installed and loaded.
If so, since the error message says the MongoClient class cannot be found, it might be caused by a namespace used in your script. If so, try
$connection = new \MongoClient($uri, $options );
Regardless of whether you are connecting locally or remotely, it seems PHP requires the mongo DB service to be running on your server. So install it like so:
a) Install mongodb service
$ sudo apt-get install -y mongodb
b) Add the php drivers if they are missing:
$ sudo apt-get install php5-dev php5-cli php-pear -y
$ sudo pecl install mongo
c) Then open your php.ini file and add to it the extension line "extension=mongo.so":
$ sudo vi /etc/php5/apache2/php.ini
> extension=mongo.so
d) Then restart apache
$ sudo service apache2 restart
Disclaimer: This example was tried on Ubuntu 14.04 LTS with Apache web-service and PHP5 installed. If your installation is different, follow the same approach but issue appropriate commands. If you have no access to SSH or sudoer privileges, contact someone who can help you do this.
I am integrating a payment gateway using SOAP. When i am calling service function using Wamp its working well. But on my live server it is giving folloing error- Class 'SoapClient' not found
the code i am using is
<?php
try
{
$soap_client=new SoapClient("WebServiceLink/service.asmx?WSDL");
$quote=$soap_client->PGI_TRANS("PassedParameter");
echo $quote->PGI_TRANSResult;
}
catch(SoapFault $exception)
{
echo $exception->getmessage();
}
?>
enable your soap extension in php.
open php.ini find the line have "php_soap" and uncomment this line,
restart web server, problem solved.
You shouldn't have to modify php.ini to enable soap on modern distributions. If it's not enabled, the package probably isn't installed. Once you install the correct package, your distro should enable the correct php.ini settings for you.
On Ubuntu:
sudo apt-get install php-soap
will install and enable the soap extensions for you.
You have to inherit nusoap.php class and put it in your project directory, you can download it from the Internet.
Download Link: http://sourceforge.net/projects/nusoap/
Use this code:
require_once('nusoap.php');
For Ubuntu17.10 Artful I've used the following command to view exact package name (it can be different).
>> apt-cache search php | grep -i soap
libnusoap-php - SOAP toolkit for PHP
php7.1-soap - SOAP module for PHP
python-pysimplesoap - simple and lightweight SOAP Library (Python 2)
python3-pysimplesoap - simple and lightweight SOAP Library (Python 3)
php-soap - SOAP module for PHP [default]
php5.6-soap - SOAP module for PHP
php7.0-soap - SOAP module for PHP
php7.2-soap - SOAP module for PHP
That's how I get the name. Then just install it.
sudo apt-get install php5.6-soap
P.S. Don't forget to update repository sudo apt-get install php-soap
For Ubuntu, running the following commands fixed my issue,
sudo apt-get install php-soap
then run
sudo service apache2 restart
I am uploading my website on to a server, and it uploaded successfully. After that, when I run, it gives me this error:
Fatal error: Call to undefined function mcrypt_get_block_size().
I also check my PHP version on my server is 5.3.14. I couldn't figure out how I can deal with this. I used this function for query string encryption. I searched about this on Google and some people say you have to ask your host to install it. Is there another way to install this or alternate function that work just like this mcrypt_get_block_size()?
You have to install and enable mcrypt.
On a Debian based Linux distribution (like Ubuntu), run this from command line:
sudo apt-get install php5-mcrypt
As Alex said, you need to install the library, but don't forget to enable it.
sudo apt-get install mcrypt php5-mcrypt
sudo php5enmod mcrypt
sudo /etc/init.d/apache2 restart
I installed unixODBC by using apt-get install, and now when I try to use odbc_connect() is still get this error.
PHP Fatal error: Call to undefined function odbc_connect()
what do i need to do to configure it to work with php? I have been looking online but I can't really figure it out.
I think you need to install php5-odbc also. unixODBC provides the driver manager, but you need the PHP code that calls it.
Had the same issue on CentOS 6.3 with PHP 5.3.16. But the fix was to use yum to install php-odbc.
yum install php-odbc
Did you add it to your LD_LIBRARY_PATH? Check the documentation for your server, it may require third-party libraries to be in a specific sub-directory, or have some other mechanism for finding them. If so, you should be able to create a symbolic link to the library. That way, if it gets updated, your server will automatically use it.
We had this problem also. We installed php5-odbc, and still had the problem. Turns out we needed to reboot Linux for php to see the function. Recycling Apache was not enough!
Make sure to enable odbc extension for your Apache by a2enmod odbc.
Then check if exists by: apache2ctl -M.
If you don't have this extension, install via apt-get install php-odbc (use yum in case of CentOS).
See also: Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS.