yandoo Posted February 5, 2008 Share Posted February 5, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/89566-fatal-error-call-to-undefined-function-pg_connect/ Share on other sites More sharing options...
btherl Posted February 6, 2008 Share Posted February 6, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/89566-fatal-error-call-to-undefined-function-pg_connect/#findComment-459314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.