php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7529 pg_connect() returns invalid connection id
Submitted: 2000-10-30 05:35 UTC Modified: 2001-02-13 12:10 UTC
From: sugino at mba dot nifty dot ne dot jp Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 4.0.3pl1 OS: Linux (Redhat 6.0)
Private report: No CVE-ID: None
 [2000-10-30 05:35 UTC] sugino at mba dot nifty dot ne dot jp
Assuming that both pg_connect() and pg_close() are called
inside a function, and then pg_connect() is called again
from the main program, the next error will occur:
"Warning: 1 is not a valid PostgreSQL link resource in ..."

examples:

1. NG

function foo() {
  $conn = pg_connect(...);
  ...
  pg_close($conn);
}

foo(); # calls pg_connect() and pg_close()

$conn = pg_connect(...);  # returns invalid connection id

2. OK

$conn = 0; # defines $conn as a global variable

function foo() {
  global $conn;
  $conn = pg_connect(...);
  ...
  pg_close($conn);
}

foo(); # calls pg_connect() and pg_close()

$conn = pg_connect(...); # returns VALID connection id



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-13 12:10 UTC] thies@php.net
believed to be fixed in CVS
 [2001-02-13 12:10 UTC] thies@php.net
believed to be fixed in CVS
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC