Jump to content

Fatal error: Call to undefined function pg_connect()


yandoo

Recommended Posts

Hi there,

 

I followed a tutorial : http://forums.devnetwork.net/viewtopic.php?f=28&t=29084

 

And every time i open the page i get this error: Fatal error: Call to undefined function pg_connect() line 46....

 

 

that points to  this line:

$this->conn = $funct($connstr);

 

Heres the whole page:

<?php

class DB
{

var $database="test";
var $user="root";
var $password="";
var $host="awakening";
var $port="5432";
var $persistent=false;

// Connection handle
var $conn=NULL;

// Query Result
var $result=false;
var $row=0;

function DB($database,$user=false,$password=false,$host=false,$port=false,$persistent=false)
{
$this->database = $database;
if ($host) $this->host = $host;
if ($user) $this->user = $user;
if ($password) $this->password = $password;
if ($port) $this->port = $port;
$this->persistent = $persistent;
}

function open()
{
// Choose the appropriate open function
if ($this->persistent) {
$funct="pg_pconnect";
} else {
$funct="pg_connect";
}
// Build the connection string
if (!empty($this->host)) $connstr.="host=".$this->host."";
if (!empty($this->port)) $connstr.="port=".$this->port."";
if (!empty($this->user)) $connstr.="user=".$this->user."";
if (!empty($this->password)) $connstr.="password=".$this->password."";
if (!empty($this->database)) $connstr.="dbname=".$this->database;

// Try connection
$this->conn = $funct($connstr);
if (!$this->conn) {
return false;
}

return true;
}

function close()
{
return (pg_close($this->conn));
}

function error()
{
return (pg_last_error());
}

function query($sql="")
{
$this->result = pg_exec($this->conn, $sql);
$this->row=0;

return ($this->result!=false);
}

function affectedRows()
{
return(pg_affected_rows($this->result));
}

function numRows()
{
return(pg_num_rows($this->result));
}

function fetchAssoc()
{
if ($this->row >= pg_num_rows($this->result)) return false;
return (pg_fetch_array($this->result,$this->row++,PGSQL_ASSOC));
}

function freeResult()
{
$this->row=0;
return (pg_free_result($this->result));
}
}
?> 

 

 

Any help be great :)

 

Thanks

 

That means that the postgresql extension for php is not installed (or is not configured for use with php).  Are you using windows or unix?  Each has a slightly different way to enable the extension.  The file php.ini controls which extensions are loaded.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.