Codice PHP:
class Database
{
var $config;
var $p_connect = false;
var $db;
var $num_query = 0;
function Database($config, $p_connect)
{
$this->config = $config;
$this->p_connect = $p_connect;
$this->num_query = 0;
$this->connect();
$this->select_db();
}
function connect()
{
if ($this->p_connect == true)
$this->db = mysql_pconnect($this->config['dbhost'], $this->config['dbuser'], $this->config['dbpass']);
else
$this->db = mysql_connect($this->config['dbhost'], $this->config['dbuser'], $this->config['dbpass']);
if (!$this->db)
die('Unable to connect to MySQL server. MySQL reported: '.mysql_error());
}
function select_db()
{
if(!mysql_select_db($this->config['dbname']))
die('Unable to select database. MySQL reported: '.mysql_error());
}
# .................
Errore: Unable to select database. MySQL reported: No database selected