Reply to Error management : php-pgsql.

Your name:

Reply:


Posted by David W on 12/07/05 21:46

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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация