Error when connect to database mysql?
<p>I have a database name : demo, table test(id, name) and using wampserver</p>

<p>In config.php</p>

<pre><code>define('MYSQL_HOST','localhost'); // your db's host
define('MYSQL_PORT',3306);        // your db's port
define('MYSQL_USER','root'); // your db's username
define('MYSQL_PASS',''); // your db's password
define('MYSQL_NAME','demo');   // your db's database name
define('DBCHAR','utf8'); // The DB's charset
</code></pre>

<p>In class.database.php</p>

<pre><code>  class DBConnect {
        private static $instance;
        private $connected = FALSE;

        public static function singleton() {
            if (!isset(self::$instance)) {
                $c              = __CLASS__;
                self::$instance = new $c;
            }
            return self::$instance;
        }

        public function __clone() {
            if (DB_SHOW_ERRORS === TRUE) trigger_error('We can only declare this once!', E_USER_ERROR);
            else die();
        }

        public function __construct() {
            if (version_compare(PHP_VERSION,'5.1.5','&lt;')) die('Sorry, class only valid for PHP &amp;gt; 5.1.5, please consider upgrading to the latest version');
            try {
                @$this-&gt;db = new mysqli(MYSQL_HOST,MYSQL_USER,MYSQL_PASS,MYSQL_NAME,MYSQL_PORT);
                if (mysqli_connect_error()) throw new Exception('Sorry, no DB connection could be made, please run in circles while an administrator checks the system: '.mysqli_connect_error());
                else $this-&gt;connected = TRUE;
            } catch(Exception $e) {
                if (DB_SHOW_ERRORS === TRUE) trigger_error($e-&gt;getMessage(),E_USER_ERROR);
                else die();
            }
            if ($this-&gt;connected === TRUE) $this-&gt;db-&gt;set_charset(DBCHAR);
        }

        public function __destruct() {
            if ($this-&gt;connected === TRUE) $this-&gt;db-&gt;close();
        }
    }

    class DBMysql {
        private $db = null;
        public function __construct() {
            $db_connect = DBConnect::singleton();
            $this-&gt;db   = $db_connect-&gt;db;
        }

        function getList() {
            $data = array();
            $sql = 'Select id, name From test';
            $query = mysql_query($sql);
            if(!$query) {
                echo "Error: " . mysql_error();
                exit;
            }
            while($row = mysql_fetch_object($query)) {
                $data[] = $row;
            }
            return $data;
        }
    }
</code></pre>

<p>And final is file test.php</p>

<pre><code>include('config.php');
include('class.database.php');
$mysql = new DBMysql(); 
$lists = $mysql-&gt;getList();
print_r($lists);
</code></pre>

<p>When i run localhost/demo/test.php is error in firebug is "<code>Error: No database selected</code>", How to fix it ?</p>
