Jump to content

problem with multiple mysal databases


Ravi Kumar

Recommended Posts

Hi All

Here is my problem.

I have PHP 5 and MYSQL 4.1 installed on my server machine.

Now we want to upgrade to mysql 5.For this we have installed MySql 5.0 on one of our machines and
using this machine's ip address to connect to MySql.

Our application is behaving strangely.

It is pulling information from mysql 4 database in some pages which it shouldn't and in other pages it is pulling information from mysql 5 database though the ipaddress of the DBHOST is pointed to MYSQL 5.

We have cross checked all the configuration files and $DBHOST variable in connection class.

Please go through the below code snippet

class samplebl
{
        private $conn;

        function __construct()
        {
$this->conn = DbFactory::getWriter();
}

function __destruct()
{
DbFactory::close($this->conn);
}

        function getData()
        {
              //this is supposed to pull data from 172.16.*.*
              $result = mysql_query("select * from products");
        }
}


class DbFactory
{
        public static function getReader()
{
                //dbhost is pointing to mysql 5.0 on following address.Mysql 4 is on same machine.
return self::connect('172.16.*.*', 'root', '');
}

public static function getWriter()
{
return self::connect('172.16.*.*', 'root', '');
}

private static function connect($dbHost, $dbLogin, $dbPassw)
{
$conn = mysql_connect($dbHost, $dbLogin, $dbPassw);

if (!$conn)
{
  die('Could not connect: ' . mysql_error());
$conn = false;
}
else
{
;
}

return $conn;
}

public static function close($conn)
{
if ($conn)
{
mysql_close($conn);
}
}
}



Please help me on this.
Waiting for a response....

Ravi Kumar

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.