db = "db_name"; $this->server = "db_server"; $this->user = "db_user"; $this->password = "db_password"; } function openConnection() { $this->linkDB = mysql_connect($this->server, $this->user, $this->password) or die("Connessione al server fallita: " . mysql_error()); mysql_select_db($this->db, $this->linkDB) or die("Connessione al database fallita: " . mysql_error()); return $this->linkDB; } function getRecordset($q) { $res = mysql_query($q, $this->linkDB) or header("Location: error.php"); $num_row = mysql_num_rows($res); return $res; } function exec($q) { $res = mysql_query($q, $this->linkDB) or header("Location: error.php"); } function close() { mysql_close($this->linkDB); } function getSingleValue($q) { $res = mysql_query($q, $this->linkDB) or header("Location: error.php"); $row = mysql_fetch_row($res); return $row[0]; } } ?>