/**
* Connects to database, with database selection
* PHP 4 constructor calls php 5 constructor
*/
function ulokidb($hostname,$dbuser,$dbpass,$dbname) {
return $this->__construct($hostname,$dbuser,$dbpass,$dbname);
}
/**
* Connects to database and selects db. If connection successfull then returns resource link,
* else echo's error's and returns false.
* PHP 5 constructor
*
* @param string $hostname MySQL hostname
* @param string $dbuser MySQL username
* @param string $dbpass MySQL password
* @param string $dbname MySQL database name
* @return bool
*/
function __construct($hostname,$dbuser,$dbpass,$dbname) {
global $config;
if(!$this->dblink) {
if($this->dblink=mysql_connect($hostname,$dbuser,$dbpass)){
if(mysql_select_db($dbname,$this->dblink)){
return $this->dblink;
}else{
die("Database cant be selected.");
return false;
}
}
else{
die("No connection can be established.");
return false;
}
}
else{
return $this->dblink;
}
}