I want to connect to PostgreSQL in linux with php in windows.
Fatal error:Call to undefined function pg_connect()
Thank you.
PDO would be prefer to connet database. For this you need to enable PDO for pg_sql. Please alter php.ini file for pg_sql.
$hostname = "localhost";
$database = "postsgres";
$username = "postgres";
$password = "postgres";
try{
$dbh = new PDO("pgsql:dbname=$database;host=$hostname",$username,$password);
} catch (Exception $ex) {
echo $ex->getMessage();
}