cypher_block Posted March 30, 2008 Share Posted March 30, 2008 What am I doing wrong here? $config = array('db'=>'ir_db', 'host'=>'localhost', 'username'=>'root','password'=>'root'); class connect { private $host = $config['host']; private $db =$config['db']; private $username = $config['username']; private $password = $config['password']; public function connect() { $connection = mysql_connect($this->host,$this->username,$this->password) or die('Could not connect:'.mysql_error()); $db = mysql_select_db($this->db) or die ('Could not select db:'.mysql_error()); } } I get a "Parse error: syntax error, unexpected T_VARIABLE" on line 9, which is the first private var i declare. Thanks! Link to comment https://forums.phpfreaks.com/topic/98713-error-w-mysql-connection-class/ Share on other sites More sharing options...
cypher_block Posted March 30, 2008 Author Share Posted March 30, 2008 Ok, I know part of the problem is scope, but can i not do this? apparently not because i still get an error, but dont understand why? class connect { global $config; private $host = $config['host']; private $db =$config['db']; private $username = $config['username']; private $password = $config['password']; Link to comment https://forums.phpfreaks.com/topic/98713-error-w-mysql-connection-class/#findComment-505151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.