Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

apache

xampp

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.

like image 291
Leon83 Avatar asked Mar 30 '13 19:03

Leon83


2 Answers

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

like image 124
Sáskya Gurgel Avatar answered Oct 30 '22 04:10

Sáskya Gurgel


In php.ini you need to uncomment

extension=php_pdo_pgsql.dll

extension=php_pgsql.dll

AND

extension="pgsql.so"

like image 31
sebtucknott Avatar answered Oct 30 '22 04:10

sebtucknott