Can someone who is used to using php oop help me figure out why this fails? I know there are probably a thousand classes already designed to do this and probably 100 times more efficient, but this is how I learn. From what I've read this should work but there is obviously something I'm missing.
Quick problem description: Trying to set up class to connect to mysql db. Already used a procedural test successfully connecting to db. Error is displayed as... Warning: mysql_select_db(): supplied argument is not a valid MySQL - Link resource in /var/www/html/oop.php on line 67 Database Selection to main failed. Code: Class dbConnect { var $machine; var $port; var $user; var $password; var $query; var $result; var $dbase; var $db; var $sel; function dbConnect($machine,$port,$user,$password) { $this->machine = $machine; $this->port = $port; $this->user = $user; $this->password = $password; $db = mysql_pconnect ("$machine","$user","$password") if (!$db) { die ("Initial connection to DB failed.") } $this->db = $db; } function setDbase($dbase) { $this->dbase = $dbase; $sel = mysql_select_db("$dbase",$db); if(!$db) { die ("Database Selection to $dbase failed."); } } } $dbn = new dbConnect("localhost","3306","bob","hjhyt4kl5"); $dbn->setDbase("main"); So why can't I use $db? Isn't the statement $this->db=$db making it available to the setDbase function? Larry S. Brown Dimension Networks, Inc. (727) 723-8388 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php