php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18292 mysql_close($link) close all connections
Submitted: 2002-07-12 01:53 UTC Modified: 2002-07-12 01:59 UTC
From: Beater at orgalan dot de Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.2.1 OS: Windows 2000
Private report: No CVE-ID: None
 [2002-07-12 01:53 UTC] Beater at orgalan dot de
<?php
function test()
{
	$link2 = mysql_connect('localhost', 'phpde', 'phpde');
	var_dump($link2);	
	echo mysql_error();
	mysql_select_db('ratbytes', $link2);
	echo mysql_error();
	$result = mysql_query('SELECT * FROM rb_user', $link2);
	echo mysql_error();	
	mysql_fetch_array($result);
	echo mysql_error();	
	mysql_close($link2);
	echo mysql_error();	
}

$link = mysql_connect('localhost', 'phpde', 'phpde');
var_dump($link);
echo mysql_error();
mysql_select_db('ratbytes', $link);
echo mysql_error();

test();

$result = mysql_query('SELECT * FROM rb_user', $link);
echo mysql_error();
mysql_fetch_array($result);
echo mysql_error();
mysql_close($link);
echo mysql_error();
?> 

produced following output:

resource(1) of type (mysql link)
resource(1) of type (mysql link) 
Warning: mysql_query(): 1 is not a valid MySQL-Link resource in ....test.php on line 25
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ....test.php on line 27
Warning: mysql_close(): 1 is not a valid MySQL-Link resource in ....test.php on line 29

... works fine if no link_identifier is specified (mysql_close)

<?php
$link = mysql_connect('localhost', 'phpde', 'phpde');
var_dump($link);
echo mysql_error();
mysql_select_db('ratbytes', $link);
echo mysql_error();

// start inline
$link2 = mysql_connect('localhost', 'phpde', 'phpde');
var_dump($link2);	
echo mysql_error();
mysql_select_db('ratbytes', $link2);
echo mysql_error();
$result = mysql_query('SELECT * FROM rb_user', $link2);
echo mysql_error();	
mysql_fetch_array($result);
echo mysql_error();	
mysql_close($link2);
echo mysql_error();	
// end inline

$result = mysql_query('SELECT * FROM rb_user', $link);
echo mysql_error();
mysql_fetch_array($result);
echo mysql_error();
mysql_close($link);
echo mysql_error();
?> 

produced following output:
resource(1) of type (mysql link)
resource(1) of type (mysql link)

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-12 01:59 UTC] mfischer@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.

See the $new_link parameter at php.net/mysql_connect
 [2004-03-08 04:47 UTC] php at netsector dot net
This bug appear again in PHP4.3.3 on W2k!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Aug 17 13:01:28 2024 UTC