Page 1 of 1

unable to connect to postgresql database in php using xampp

PostPosted: 15. January 2015 08:10
by pavi_elex
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
<?php
$dbconn=pg_connect("host=hostname port=5432 dbname=dbname user=username password=password");
if(!$dbconn)
{
echo 'Not Connected';
}
else
{
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.

Thanks