Jump to content

Fatal error: Call to undefined function pg_connect()


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.