Amit Dhamu

Writes Code

Database Class

class Database {

  private $db_host = '';      // Database Host
    private $db_user = '';      // Username
 private $db_pass = '';      // Password
 private $db_name = '';      // Database

  private $con = false;               // Checks to see if the connection is active
  private $result = array();          // Results that are returned from the query

     /* Connects to the database, only one connection allowed */
       public function connect() {
       if(!$this->con) {
         $myconn = @mysql_connect($this->db_host,$this->db_user,$this->db_pass);

         if($myconn) {
             $seldb = @mysql_select_db($this->db_name,$myconn);
                            if($seldb) {
                              $this->con = true;
                                    return true;
                          } else {
                              return false;
                         }
                 } else {
                          return false;
                     }
         } else {
              return true;
          }
     }

       /* Disconnect */
  public function disconnect() {
        if($this->con) {
          if(@mysql_close()) {
              $this->con = false; 
              return true; 
         } else {
              return false; 
            }
     }
 }       
}


database / class / database connect

← Hover Animations Detect CSS Property →