Location: PHPKode > scripts > PHP Address book > php-address-book_v_1.01_eng/php-address-book_v_1.01_eng/classes/database.class.php
<?php

class database{

    private $username;
    private $password;
    private $location;
    private $database;

    public function __construct($username, $password, $location, $database) {
        $this->username = $username;
        $this->password = $password;
        $this->location = $location;
        $this->database = $database;
    }

    function connect(){
        $connect = mysql_connect($this->location,$this->username,$this->password);
        mysql_select_db($this->database, $connect);
    }
    
    function query($q){
        $this->connect();
        $r = mysql_query($q) or die("Er is een fout opgetreden. Probeer het later opnieuw: " . mysql_error());
        return $r;
    }
    
    function escape($q){
        $this->connect();
      
        $r = mysql_real_escape_string($q);
        return $r;
    }    

    function validateMail($email){
        if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) {
            return true;
        } else {
            return false;
        }
    }
}

?>

Return current item: PHP Address book