php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2372 use database for two different database cause all the link to point to only one
Submitted: 1999-09-24 03:46 UTC Modified: 1999-09-24 05:01 UTC
From: carmelo at melting-soft dot com Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0.12 OS: suse 5
Private report: No CVE-ID: None
 [1999-09-24 03:46 UTC] carmelo at melting-soft dot com
Suppose you have :

sql :
  Create database DB1;
  Create table A (
    aid          integer               not null ,
  );
  Create database DB2;
  Create table B (
    bid          integer               not null ,
  );

php:
<?php

      $link1=mysql_pconnect("", "root", "");
      if (!$link1) {
        exit;
      }
      $link2=mysql_pconnect("", "root", "");
      if (!$link2) {
        exit;
      }

      if (!@mysql_select_db("DB1",$link1)) {
        exit;
      }

      if (!@mysql_select_db("DB2",$link2)) {
        exit;
      }

      $queryid = @mysql_query("select * from B",$link2);
	  echo "$link2, $queryid<br>";
	  echo "error :".mysql_error()."<br>";

      $queryid = @mysql_query("select * from A",$link1);
	  echo "$link1, $queryid<br>";
	  echo "error :".mysql_error()."<br>";

?>

result:
2, 3
error :
1, 
error :Table DB2.A' doesn't exist

here it is, I think this should be enough
one last thing, there was the same bug on php4, and so I made a test under php3 to be sure it was not a php4 specific bug.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-09-24 05:01 UTC] riffraff at cvs dot php dot net
this is not a bug, but a documented feature :-)
see manual page for mysql_pconnect():

   First, when connecting, the function would first try to find a
   (persistent) link that's already open with the same host, username and
   password. If one is found, an identifier for it will be returned
   instead of opening a new connection.

this, unfortunatelly, cannot be changed in a simple way...
try to define more users for accessing mysql...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 22:01:31 2024 UTC