Carlos Gomez Carlos Gomez - 1 year ago 195
PHP Question

pg_connect not working with PHP 5

I'm working on an application that runs fine with PHP 4 in a windows 8 server. I'm setting a local server with postgres to work locally but with PHP 5 to migrate a few things. I'm having some compatibility issues but nothing big except that the pg_connect function in a class is not working and is not throwing me any error

class basededatos{
var $link_;

function basededatos(){
$this->link_=pg_connect("host=localhost port=5432 dbname=... user=postgres password=...") or die('Falla en la conexión a la Base de Datos. Por favor, Revise la Configuración.');

function cerrarconexion(){

function Abreconexionconretorno($consulta){
$resultado=pg_query($consulta)or die("La consulta falló con error: ".pg_last_error());
return $resultado;

function Abreconexionsinretorno($consulta){
pg_query($consulta)or die("La consulta falló con error: ".pg_last_error());

After this


It just dies, any idea why is this happenning? Thanks

Answer Source

Probably you don't have PostreSQL extension enabled in php.ini file because You upgraded to PHP 5. Just add this line to php.ini if pgsql module for PHP is installed:

extension=php_pgsql.dll (windows) (linux)

If the module is not installed then go with:

sudo apt-get install php5-pgsql
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download