|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70881 Fatal error: Call to undefined function pg_connect()
Submitted: 2015-11-09 04:53 UTC Modified: 2015-11-09 05:00 UTC
From: gmgoodbody at yahoo dot com Assigned:
Status: Not a bug Package: PDO PgSQL
PHP Version: 5.6.15 OS: osx 10.11.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
33 - 21 = ?
Subscribe to this entry?

 [2015-11-09 04:53 UTC] gmgoodbody at yahoo dot com
From manual page:
I upgraded to osx El Capitan and now my web development platform is all screwed up; I cannot access my postgres database from the php based webpage I am developing. I have spent over two days searching the internet for a solution but it's full of garbage. Everything I try does not work. I tried rigging the delivered php that comes with the mac, I tried installing php with homebrew using this command: brew install php56-pdo-pgsql 

Homebrew seemed to install everything but I still get the fatal undefined function pg_connect() error.

Test script:
Try to open php in Safari browser:

This is what displays on my webpage:
Fatal error: Call to undefined function pg_connect() in /Users/mymacuser/Sites/testpg.php on line 8

$host = "localhost";
$port = "5434";       //note: 5434 is the correct port
$user = "myuser"; 
$pass = "mypass"; 
$db = "mydb"; 

$con = pg_connect("host=$host port=$port dbname=$db user=$user password=$pass")
    or die ("Could not connect to server\n"); 

$query = "SELECT VERSION()"; 
$rs = pg_query($con, $query) or die("Cannot execute query: $query\n"); 
$row = pg_fetch_row($rs);

echo "Database version... <br>";
echo $row[0] . "\n";
echo "<br><br>";

Expected result:
The expected result is php would know what pg_connect() means and I wouldn't get a fatal error. Or at least there would be an easy way to know what is wrong with my installation so I can fix it.

The PHP installation process is downright horrible. You need to fix/simplify your installation process or people are going to start using a different tool for web development.

I've been searching support pages all over the web for two days and there is a lot of garbage out there. It is extremely frustrating. Installing php should NOT be this difficult.

Actual result:
My phpinfo() has this:

Additional .ini files parsed	/usr/local/etc/php/5.6/conf.d/ext-pdo_pgsql.ini


PDO support	enabled
PDO drivers	mysql, odbc, sqlite, pgsql
PDO Driver for PostgreSQL	enabled
PostgreSQL(libpq) Version	9.4.5
Module version	1.0.2
Revision	$Id: 93432550a76a2298959ec74f40d65c7195a82ad2 $


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-09 05:00 UTC]
-Status: Open +Status: Not a bug
 [2015-11-09 05:00 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You have the pdo_pgsql extension installed but are trying to use functions from pgsql extension. They are two different things.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 04:01:29 2024 UTC