note 59464 deleted from function.pg-connect by bjori

From: Date: Tue, 12 Dec 2006 08:50:39 +0000
Subject: note 59464 deleted from function.pg-connect by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-120532@lists.php.net to get a copy of this message
Note Submitter: willou.d AT gmail DOT com ---- pg_connect not seems to return a resource when the connection fail. For this example the database 'toto' doesn't exist. With the following code : <?php $cnxString = "host=localhost port=5432 dbname=toto user=username password=secret"; $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; } ?> The result on screen (php.display_errors=1) : 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 Why ? Please show me my error. Thanks. PS : (Versions) PHP Version 5.0.4 ; PostgreSQL(libpq) Version 8.0.3 ; Apache/2.0.54

« previous php.notes (#120532) next »