Hello,
I've been having a bit of trouble getting this to work, maybe I'm going about it the wrong way. What I am trying to do is take a variable from lets say config.php and use it in my database.class.php class file so I can centralise my options.
Putting an include to the config in the top of the database class doesn't seem to pull the vars into the class. Putting it just inside the class doesn't work either. How can I pull the config variables into use for the functions in this class?
For example...
config.php
Code:
$dbhost = "localhost" ;
$dbuser = "root" ;
$dbpass = "pass" ;
database.class.config
Code:
require_once "config.php" ;
class db {
function connect(){
mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to database. ')
}
}
Hopefully that helps make things a bit clearer... I need connect() to be using the vars from config!
Cheers guys...
Leonard
Last edited by Gentleman_; 12-16-2008 at 03:48 PM..
Reason: Forgot tab changed fields and tried to tab and linebreak and submitted early!
|