What is wrong with next code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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";
}
-------------------------------------------------

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux