Yeni başladım sınıflar ile çalışmaya. İlk işe yarar sınıfımı da sizinle paylaşıyorum

sinif.php
<?php

class vt {

	public $host;
	public $uname;
	public $pword;
	public $dbase;
	public $baglanti;
	public $sec;
	
	public function ayarlar($host, $uname, $pword, $dbase) {
		$this->host = $host;
		$this->uname = $uname;
		$this->pword = $pword;
		$this->dbase = $dbase;
	}

	public function baglan() {
		try {
			$this->baglanti = mysql_connect($this->host, $this->uname, $this->pword);
			$this->sec = mysql_select_db($this->dbase, $this->baglanti);
			
			if((!$this->baglanti) or (!$this->sec)) {
				throw new exception('Veritabani baglanti hatasi');
			}
		}
			catch (exception $e) {
				echo $e->getMessage();
			}	
	}
	
	public function sorgu($sorgu) {
		return mysql_query($sorgu);
	}
	
	public function kapat() {
		mysql_close($this->baglanti);
	}

}

?>
Kullanımı:
baglanti.php
<?php

include "sinif.php"; 

$host = '';
$uname = '';
$pword = '';
$dbase = '';

$vt = new vt();
$vt->ayarlar($host, $uname, $pword, $dbase);

$vt->baglan();
// MySQL işlemleri
$vt->kapat();

?>