|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-01-15 11:33 UTC] georg@php.net
[2003-01-15 11:47 UTC] darylm at magiasoftware dot com
[2003-01-15 12:48 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 09:00:01 2025 UTC |
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.