What is wrong with next code

From: Date: Fri, 29 Oct 2004 02:15:48 +0000
Subject: What is wrong with next code
Groups: php.general 
Request: Send a blank email to php-general+get-200600@lists.php.net to get a copy of this message
Can one explain me why I has got a result: ------------------------------------------------- Warning: mysql_query(): 4 is not a valid MySQL-Link resource in ... $result = mysql_query('SELECT 1+1', $db1); ------------------------------------------------- from next example. The example does not work correctly (as I expect) in PHP 4.3.8, 4.3.9, 5.0.2 It works OK in PHP 4.3.6 or when line "$db2 = 0;" had been commented in all described versions of PHP. If it's a correct behaviour in new versions of PHP so how can I free/unset $db2 variable without triggering such effect? ------------------------------------------------- error_reporting(E_ALL); $db1 = mysql_connect ('localhost', 'test', '1'); $db2 = mysql_connect ('localhost', 'test', '1'); mysql_close($db2); $db2 = 0; $result = mysql_query('SELECT 1+1', $db1); if ($result) { $row = mysql_fetch_row($result); echo "Result: {$row[0]}\n"; } -------------------------------------------------

« previous php.general (#200600) next »