PHP 4.0 Bug #9107 Updated: Function with mysql_close($conn) closes top level scripts $conn
| From: | stormlrd at majestic-quartz dot com | Date: | Mon, 05 Feb 2001 09:08:49 +0000 |
| Subject: | PHP 4.0 Bug #9107 Updated: Function with mysql_close($conn) closes top level scripts $conn | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-45761@lists.php.net to get a copy of this message | ||
ID: 9107
User Update by: stormlrd@majestic-quartz.com
Status: Open
Bug Type: *Function Specific
Description: Function with mysql_close($conn) closes top level scripts $conn
Sorry the PL4 was meant to be PHP4.04Pl1 :)
Previous Comments:
---------------------------------------------------------------------------
[2001-02-05 04:06:36] stormlrd@majestic-quartz.com
Please Also Refer to Bug Report 9049 :
I believe I am having the same problem. I think I have worked out why tho.
I have two files.
One has a function in it.
Both files require a connection to mysql database.
Both connections use the $conn as their pointer.
If you mysql_close($conn) within the function in the second file
then it closes the $conn in the script calling the function.
So you have to remove the mysql_close from your function
and even the $conn=mysql_connect from it and just pass the
$conn as a variable to the function :
eg
function foo($conn){
$result=mysql_db_query("test","select ...",$conn);
}
called from say test.html
$conn=mysql_connect("localhost","rootme","noway");
foo($conn);
was like this :
function foo()
{
$conn=mysql_connect("localhost","rootme","noway");
## query work etc..
mysql_close($conn);
return;
}
main script :
$conn=mysql_connect("localhost","rootme","noway");
#anything in here
#call function
$wotever=foo();
$result=mysql_db_query("database","query",$conn);
the last line brings up the error about the mysql link resource being wrong as the $conn was closed
in the function but somehow closed it globally too. Which is a bit of a pain as this was ok before
upgrading to Pl4
I didnt see anything in the change file about this :L So I can only assume
this is a bug.
If you need more info from me please let me know.. Thanks for all the good work guys :)
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=9107