Esempio n. 1
0
    }
    //connect to database
    function connect()
    {
        $this->connect = mysql_connect($this->server, $this->user, $this->pass);
        if (!$this->connect) {
            die("connection can not be established");
        }
        $db_select = mysql_select_db($this->database, $this->connect);
        if (!$db_select) {
            die("Database selection failed : " . mysql_error());
        }
    }
    //ping to see whether the database has gone offline or not
    private function ping_db()
    {
    }
    //sanitize query to prevent sql-injection
    function sanitize_query($query)
    {
    }
    function close()
    {
        if (isset($this->connection)) {
            mysql_close($this->connection);
        }
    }
}
$val = new db_connect();
$val->set_var($server, $user, $pass, $database);
$val->connect();