Hi, We have a database class that we want to use to connect to multiple databases at the same time using different variables. Here is part of the db class: class db { var $dbh = ""; var $q = ""; function db($db_host, $db_user, $db_pass, $db_name) { $this->dbh = @mysql_pconnect($db_host, $db_user, $db_pass); $this->select_db($db_name); } function select_db($db) { if (!@mysql_select_db($db, $this->dbh)) { die("<em>Cannot select database because:</em></p>\n<p><code>" . mysql_error() . "</code>"); } } function num_rows($_q) { if (!$this->q = mysql_query($_q, $this->dbh)) { die("Invalid query \"<code>" . $_q . "</code>\"</p>\n<p><code>" . mysql_error() . "</code>"); } else { return mysql_num_rows($this->q); } @mysql_free_result($this->q); } } In my php file I say something like <?php Include ( 'db.php' ); $db_1 = new db('server','username','password','db1'); $db_2 = new db('server','username','password','db2'); Echo $db_1->num_rows('select * from table1'); Echo $db_2->num_rows('select * from table2'); ?> Now that happens is when I try and do the query for db1, I get told that db2.table1 doesn't exist. I can swop anything around and it doesn't seem to work for one of the classes. Does anyone have any idea as to why this is happening? Thanks a lot, Ian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php