Ravi Kumar Posted September 12, 2006 Share Posted September 12, 2006 Hi AllHere 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 snippetclass 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 Quote Link to comment Share on other sites More sharing options...
btherl Posted September 12, 2006 Share Posted September 12, 2006 The mysql_*() functions have an optional "link identifier". Adding that might fix your problem.[code] mysql_query($query, $this->conn)[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.