Re: Error's management : php-pgsql.
| From: | David BOUCHE | Date: | Wed, 07 Dec 2005 20:22:52 +0000 |
| Subject: | Re: Error's management : php-pgsql. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40790@lists.php.net to get a copy of this message | ||
Hello,
i'm ok with this.
But how do you explain the example on php.net ?
And how can I get the error message ? The same error message that i've
got in my logs : "Unable to connect to PostgreSQL server: FATAL: la base
de données «toto» n'existe pas"*
*(In english : the «toto» database doesn't exists").
Thanks for your support,
David.
Bastien Koert a écrit :
Stands to reason don't you think. If you have no connection, you have no resource to handle that failure, hence no pg-last-notice. There is no error message from php since the only return from the call is 'FALSE' on login faliure... BastienFrom: David BOUCHE <willou@willou.net> To: Bastien Koert <bastien_k@hotmail.com> Subject: Re: [PHP-DB] Error's management : php-pgsql. Date: Wed, 07 Dec 2005 21:07:09 +0100 Again, the URL where i've found this script : http://www.php.net/manual/en/function.pg-last-error.php Bastien Koert a écrit :try if (!$pgsql_conn = pg_connect($cnxString, PGSQL_CONNECT_FORCE_NEW)) { print "Connexion réussie à : " . pg_host($pgsql_conn) . "<br/>\n"; } else { echo pg_last_notice($pgsql_conn); exit; } bastienFrom: David BOUCHE <willou@willou.net> To: php-db@lists.php.net Subject: [PHP-DB] Error's management : php-pgsql. Date: Wed, 07 Dec 2005 20:46:34 +0100 Hello, My goal : obtain the error message if the connection fail. ## my code : <?php $cnxString = "host=localhost port=5432 dbname=toto user=atlante password=aiThoo3g"; $pgsql_conn = pg_connect($cnxString, PGSQL_CONNECT_FORCE_NEW); if ($pgsql_conn) { print "Connexion réussie à : " . pg_host($pgsql_conn) . "<br/>\n"; } else { echo pg_last_notice($pgsql_conn); exit; } ?> ## if «php_value display_errors 1» the screen result is this one : Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server: FATAL: la base de données «toto» n'existe pas in /home/willou/public_html/atlanpolis/wwws/tools/checkdb.php on line 5 Warning: pg_last_notice() expects parameter 1 to be resource, boolean given in /home/willou/public_html/atlanpolis/wwws/tools/checkdb.php on line 10 ## If not, i haven't got any result. The message just appears in my logs The return of pg_connect not seems to be an connection resource when the connection fails. Thanks to help me to find the problem, David.