unable to connect to postgresql database in php using xampp

Problems with the Linux version of XAMPP, questions, comments, and anything related.

unable to connect to postgresql database in php using xampp

Postby pavi_elex » 15. January 2015 08:10

I am facing a problem in XAMPP. I am using UBUNTU operating system (or sometimes CentOS). I have installed XAMPP 1.8.3-4 (before XAMPP 1.8.1 ) in both Operating systems (as /opt/lampp). I am not able to connect to postgresql database using php file in any version of xampp.
I have written following code in a php file.
Code: Select all
$dbconn=pg_connect("host=hostname port=5432 dbname=dbname user=username password=password");
echo 'Not Connected';
echo "Connected";

I have saved this file as connection.php inside htdocs. Now when I run http://localhost/connection.php in browser
It gives me following error.
Code: Select all
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host.....ssl off

When I checked my phpinfo.php, I found "SSL support disabled" there. Please see Image
I think this is the problem that's why I am not able to connect to pgsql database. I do not know, how to make SSL support enabled.

My senior has installed individual packages apache, mysql, php, pgsql on his ubuntu using command line (sudo apt-get install package-name) and he is able to connect to pgsql database using same file but I am not able to connect because I am using xampp.
I have checked my senior's phpinfo.php, the only difference between my senior's phpinfo and mine is the SSL support for pgsql. His SSL support is enabled.
That's why I have been told to install individual packages but I do not want to leave xampp. Please give me solution to connect pgsql database.

Posts: 2
Joined: 15. January 2015 07:51
Operating System: ubuntu / centos

Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 5 guests