Class & Connection Problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
liquidchild
Forum Newbie
Posts: 9
Joined: Sun Nov 03, 2002 6:25 am

Class & Connection Problems

Post by liquidchild »

I am getting nothing from the code below, I am not a hundred percent sure about using class and methods within the class in php so this may be part of the problem, however i have created a new instance of both MysqlProp and MysqlConn, as you can see, MysqlProp contains things like host, user, etc and has mutator and get methods. However it appears that nothing is being returned as when i do echo "$$this->_mysql_prop->getHost(), i am getting nothing returned while in mysqlProp there is a method:

function getHost()
{
return $_host;
}

with $_host being defined as var $_host = 'localhost'; surely this should return localhost, where am i going wrong. Thanks


/** Sets the parameters required to connect to the database **/

function _setConnection()
{
/** Creates a new properties instance using the MysqlProperties defaults
$this->_mysql_prop = new MysqlProperties();

/** Creates a new connection instance **/
$this->_mysql_conn = new MysqlConnect();

/** Set the properties of this connection **/
$this->_mysql_conn->setProperties( $this->_mysql_prop->getHost(), $this->_mysql_prop->getUser(), $this->_mysql_prop->getPassword() );

/** Connect to the database **/
$this->_mysql_conn->connectMysql();
}
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

maybe

Code: Select all

class ...
{
[...]
	function getHost()
	{
		return $this->_host;
	}
[...]
}
[...]
echo $this->_mysql_prop->getHost();
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Post Reply