I am using the db_mysql class from phplib but i want the servername, password etc variables to be in a different file that has already been included (or could be included from inside db_mysql.
How do i do this? using global did not work
| SitePoint Sponsor |



I am using the db_mysql class from phplib but i want the servername, password etc variables to be in a different file that has already been included (or could be included from inside db_mysql.
How do i do this? using global did not work





Try putting this in the class:
etc.PHP Code:var $username = $username;
var $password = $password;
Or you could declare the variables with var $variable as blank, then fill them in when you initiate the class in a script like this:
PHP Code:$class->username = $username;
$class->password = $password;



tried both of these, am complety stuck.
This is for example my top of the class:
and this is my include type file:PHP Code:class DB_Sql {
/* public: connection parameters */
var $host = "localhost";
var $database = "";
var $user = "root";
var $password = "";
PHP Code:$db = new DB_Sql;
$dbname="deskpro";
$db->user=$user;
$db->password=$password;
$db->host=$host;
$db->dbname=$dbame;
if i run the 2nd file, i always get the error
whatever happens. The name is not getting into the class.Code:Database error: cannot use database MySQL Error: 1046 (No Database Selected) Session halted.
doing var $username = $username; gave a syntax errror. The 2nd way is the way vb does it but i can't get it to work! any idea what i am doing wrong?



problem solved, don't worry![]()
Bookmarks