ID:               38689
 Comment by:       judas dot iscariote at gmail dot com
 Reported By:      nerdystudmuffin at gmail dot com
 Status:           Open
 Bug Type:         MySQL related
 Operating System: Linux, XP, NT, 2K
 PHP Version:      5.1.6
 New Comment:

this is actually the expected behaviuor.

use the 4th parameter of mysql_connect see :

http://php.net/manual/en/function.mysql-connect.php

not a bug, but a feature. ;)


Previous Comments:
------------------------------------------------------------------------

[2006-09-02 05:07:13] nerdystudmuffin at gmail dot com

Description:
------------
Generating two database handles to the same server with the same
authentication and selecting different databases for them. They act as
a single connection and will only return results from the last database
selected.

Reproduce code:
---------------
$server ="localhost";
$user="sql_admin";
$pass="password";
$num_query = "SELECT * FROM aqs_users WHERE 1";
$num_db = "aqs";
$anum_query = "SELECT * FROM w_dagent_hierarchy WHERE
row_date='2005-08-08'";
$anum_db = "dbviews";
$num = mysql_connect($server,$user,$pass);
$anum = mysql_connect($server,$user,$pass);
### LINEAR
mysql_select_db($num_db,$num);
mysql_select_db($anum_db,$anum);
$num_res = mysql_query($num_query,$num);
$anum_res = mysql_query($anum_query,$anum);
$num_row = mysql_fetch_row($num_res);
$anum_row = mysql_fetch_row($anum_res);
echo "<pre>"; print_r($num_row); echo "</pre>";
echo "<pre>"; print_r($anum_row); echo "</pre>";
mysql_close($num); mysql_close($anum); unset($num_res);
unset($anum_res); unset($num_row); unset($anum_row);
echo "<hr>";
$num = mysql_connect($server,$user,$pass);
$anum = mysql_connect($server,$user,$pass);
mysql_query("USE aqs",$num);
mysql_query("USE dbviews",$anum);
$num_res = mysql_query($num_query,$num);
$anum_res = mysql_query($anum_query,$anum);
$num_row = mysql_fetch_row($num_res);
$anum_row = mysql_fetch_row($anum_res);
echo "<pre>"; print_r($num_row); echo "</pre>";
echo "<pre>"; print_r($anum_row); echo "</pre>";
mysql_close($num); mysql_close($anum); unset($num_res);
unset($anum_res); unset($num_row); unset($anum_row);

Expected result:
----------------
I would expect both querys to run and display a formatted print_r() of
the results.

Actual result:
--------------
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in D:\AQS\testme.php on line 64

Array
(
    [0] => 1
    [1] => CENSORED
    [2] => CENSORED
    [3] => 15
    [4] => 0
    [5] => 4
)


Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in D:\AQS\testme.php on line 82

Array
(
    [0] => 2005-08-08
    [1] => 0011f25.0000010
    [2] => 2300
    [3] => CENSORED
    [4] => 
    [5] => CENSORED
    [6] => CENSORED
    [7] => 0021d02.0000004
    [8] => Mid
    [9] => CENSORED
    [10] => CENSORED
    [11] => Full-time
    [12] => CENSORED
    [13] => 2003-12-08
    [14] => 0000-00-00
)



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38689&edit=1

Reply via email to