Skip site navigation (1) Skip section navigation (2)

pg_last_error() doesn't return connection errors

From: Frank Naude <naudefj(at)gmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: pg_last_error() doesn't return connection errors
Date: 2010-08-26 11:44:44
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-php

I can successfully connect to PostgreSQL (pgsql extension). However,
when I make a deliberate mistake, I'm unable to capture the connection
error with pg_last_error() as one would with the *_last_error()
functions of other database extensions.

Here is an example:

$c = pg_connect('host= user=postgres password=xxx
dbname=yyy') or var_dump( pg_last_error() );

The following output (with warnings) is returned:

Warning: pg_connect() []: Unable to connect to
PostgreSQL server: FATAL: password authentication failed for user
"postgres" in ..
Warning: pg_last_error() []: No PostgreSQL link
opened yet in ...

One would expect pg_last_error() to return "password authentication
failed" instead of FALSE!

Best regards.



pgsql-php by date

Next:From: Andrew McMillanDate: 2010-08-26 22:44:33
Subject: Re: pg_last_error() doesn't return connection errors
Previous:From: ChrisDate: 2010-07-27 23:27:50
Subject: Re: Arrays and PDO

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group