Re: PHP pg_connect

Поиск
Список
Период
Сортировка
От Hannes Dorbath
Тема Re: PHP pg_connect
Дата
Msg-id 469C73AA.2010802@theendofthetunnel.de
обсуждение исходный текст
Ответ на PHP pg_connect  (Vince <vincej@gmail.com>)
Ответы Re: PHP pg_connect  (Hannes Dorbath <light@theendofthetunnel.de>)
Список pgsql-general
On 17.07.2007 09:13, Vince wrote:
> When this fails, I get a useful error print:
>
> $dbconn = pg_connect($connection_str);
>
> Ouput:
>
> Warning: pg_connect() [function.pg-connect]: Unable to connect to
> PostgreSQL server: FATAL: password authentication failed for user
> "postgres1" in ...
>
> How do I capture this error and handle the printing myself?  I want to
> be able to know why it failed... ie password in this case.

This is a PHP, not a PostgreSQL question.

if (!pg_connect()) {
   if (preg_match('/authentication\sfailed/', pg_last_error())) {
     echo "Oh dear, you lost your password?\n";
   } else if (true) {
     echo "OMG, something else went wrong!\n";
   }
}


--
Regards,
Hannes Dorbath

В списке pgsql-general по дате отправления:

Предыдущее
От: "Jason Nerothin"
Дата:
Сообщение: interaction with postgres defined types in custom c functions
Следующее
От: Hannes Dorbath
Дата:
Сообщение: Re: PHP pg_connect