|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-09-02 05:13 UTC] judas dot iscariote at gmail dot com
[2006-09-02 06:38 UTC] tony2001@php.net
[2006-09-02 12:41 UTC] nerdystudmuffin at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 03:00:01 2025 UTC |
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 )