php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5143 mysql_query() queries the last opened link, not the specified link
Submitted: 2000-06-20 12:21 UTC Modified: 2000-07-27 20:28 UTC
From: paolo at mailgate dot net Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.0 Latest CVS (20/06/2000) OS: Redhat 5.2
Private report: No CVE-ID: None
 [2000-06-20 12:21 UTC] paolo at mailgate dot net
----------------------------------------------------------------------------
$conn = mysql_connect( 'localhost','infoline','xxxxx');
if (!$conn) print "Error connecting";
$res = mysql_select_db('egg',$conn);
if (!$res) print "Error changing database";

$conn2 = mysql_connect( 'localhost','infoline','xxxxx');
if (!$conn2) print "Error connecting";
$res2 = mysql_select_db('infosat',$conn2);
if (!$res2) print "Error changing database";

$query = 'select * from sat_connections';
$result = mysql_query($query,$conn);
if (!$result) print 'Error doing SQL query: '.mysql_error();
-----------------------------------------------------

The result of all this is an error:
Error doing SQL query: Table 'infosat.sat_connections' doesn't exist

which is true. sat_connections exists in the database 'egg', but not in
the database 'infosat'. This probably means that mysql_query() always
queries the last opened connection, unlike what the documentation
states.

Please note that I am using the first release of PHP4, which does not appear as an option above.

I don't currently have access to the list of compiled modules, etc., but I suspect this is a general problem. If this is not the case, please mail me and I will get hold of further info.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-27 20:28 UTC] jalal@php.net
This is correct functioning.
$conn and $conn2 represent the same server, and will act on the last opened database there.

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 23:00:01 2026 UTC