Cant connect to Postgres from php ->Call to undefined function pg_connect()

apache, php, xampp

Solution

In the C:\xampp\php\php.ini , uncomment these:

extension=php_pdo_pgsql.dll
extension=php_pgsql.dll

After Done this Need to restart your xampp

Problem

I posting this question as answers in previews posts didn't help me. i am trying to connect to DB postgres which is located on remote server from my local computer. I am using Xampp and Netbeans IDE. below is the code i am trying to run : ``` //attempt a connection $dbh = pg_connect("host=server_name port=5432 dbname=prototype1 user=leonidz password=****"); if (!$dbh) { die("Error in connection: " . pg_last_error()); } ``` This is the error msg: ``` Fatal error: Call to undefined function pg_connect() in C:\xampp\htdocs\PhpProject1\index.php on line 10 ``` in php.ini I uncommitted: extension=php_pgsql.dll and extension=php_pdo_pgsql.dll i also mapped the extension_dir = "C:\xampp\php\ext\" and restarted the Apache server after the change. I don't know what else i should do, please help.

Original source