#18913 [Opn->Bgs]: pg_pconnect fails when trying to connect to a different DB

From: Date: Thu, 15 Aug 2002 08:37:20 +0000
Subject: #18913 [Opn->Bgs]: pg_pconnect fails when trying to connect to a different DB
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16890@lists.php.net to get a copy of this message
ID: 18913 Updated by: sander@php.net Reported By: jc@mega-bucks.co.jp -Status: Open +Status: Bogus Bug Type: PostgreSQL related Operating System: Red Hat Linux 7.2 PHP Version: 4.2.2 New Comment: There's a ini-directive that limits the maximum number of persistant connections. See phpinfo(). Previous Comments: ------------------------------------------------------------------------ [2002-08-15 03:30:50] jc@mega-bucks.co.jp It seems that I cannot use pg_pconnect to connect to more than on database at a time? The following code fails with this error: Warning: pg_pconnect() cannot create new link. Too many open links (1) in /www/htdocs/jc/t2.php on line 26 Warning: pg_exec(): supplied argument is not a valid PostgreSQL link resource in /www/htdocs/jc/t2.php on line 27 CONNECTION: could not execute query2 (select now()) <?php $sql = "select now()"; //uncommenting one of the following lines will make the code work $res1 = sql_query($sql); $res2 = sql_query2($sql); $dat = pg_fetch_object($res1); //or res2 as the case maybe echo $dat->now; function sql_query($sql) { $conn = pg_pconnect("dbname=JC user=postgres"); $res = pg_exec($conn, $sql); if (!$res) { echo "CONNECTION: could not execute query ($sql)<br>"; die; } else { return $res; } } function sql_query2($sql) { $conn = pg_pconnect("dbname=sessions user=postgres"); $res = pg_exec($conn, $sql); if (!$res) { echo "CONNECTION: could not execute query2 ($sql)<br>"; die; } else { return $res; } } ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18913&edit=1

« previous php.bugs (#16890) next »