Search code examples
phpwindowspostgresqlvisual-studio-codexampp

Uncaught Error: Call to undefined function pg_connect() using XAMPP on Windows


I have this problem when I try to run connect.php with this code:

$conn = pg_connect("host=localhost dbname=books user=postgres password=123 port=5434");
if($conn){
    echo "success";
}

I work with Visual Studio Code and I download the package postgreSQL. After that I restart the XAMPP and nothing happend. I remove semicolon in php.ini -> extension=php_pdo_pgsql.dll but the same problem occurs...


Solution

  • You need to enable pgsql.dll if you want to use pg_*() functions.

    You enabled php_pdo_pgsql.dll which allows for connecting to PG DBs using the PDO extension.