From:             [EMAIL PROTECTED]
Operating system: Unix (FreeBSD)
PHP version:      4.2.3
PHP Bug Type:     MySQL related
Bug description:  Functions closing mysql resources

There are two databases involved:
database1 is connected to in the main body of the page
database2 is connected to in a function

========================================================
function foo()
{
   mysql_connect(Same Arguements)
   db1_connection = select_db (db1)
   do something
   close db1_connection
}

mysql_connect(Same Arguements)
db2_connection = select_db(db2)

do something with db1

foo()

do something with db1 //**** This will fail
======================================================

The second "do something with db1 will fail with a "not a valid result
resource" error.  I percieve of two possible reasons for this:

1.  mysql_close(db1_connection) is closing all the links

or, most likely

2.  Since mysql_connect is called with the same arguements it returns the
same resource id (I know this) then, when I close db1_connection it closes
 that resource.

So, either way we have a variable scope issue.  According to what I
understand about the scope rules of php the functions should have no
knowledge of my connection to db2 unless I declare it as global in the
function foo.  But, it does anyway.

As an aside, I used to be able to globally include a resource id into a
function, leave it open and return from the function.  Now, it appears
that when the function exits it disposes of the "global" resource in its
clean up proceedures.
-- 
Edit bug report at http://bugs.php.net/?id=21663&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21663&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21663&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21663&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21663&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21663&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21663&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21663&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21663&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21663&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21663&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21663&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21663&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21663&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=21663&r=gnused

Reply via email to