hello all,

I am currently working on a project and having serious issue with the class that I am using.

Considering that my database class in fully functional as I use it in other classes and they work fine they, what is the problem with this kind of design. WHy are the class functions not working properly?

In my project, the class is supposed to be used in over 30 pages and I don't putting the same code in 30 pages is not a good practise.

Code:
<?php

require_once('connect.inc');

Class Commonutil{

	function Commonutil(){}

   
	//reduce pin access statuys
	function reducePinAccessStatus($status, $pin)
	{
		$condbM = $this->getConnectionObject();
		$access = --$status;
		$reducePinAccessStatusquery = sprintf("update Library set status = &#37;d where pin = sha1('%s')", $access, $pin);
		$updateOp = $condbM->getQuery($reducePinAccessStatusquery);
		if ($access < 1) 
		{//access used up? call changePinStatus($pin)
			$this->changePinStatus($pin);
		}
		$condbM->close();
	}
	
	//change the used status of the pin to true
	function changePinStatus($pin)
	{
		$changePinStatusquery = sprintf("update Library set used = 'true' where pin = sha1('%s')", $pin);
		$condbM = $this->getConnectionObject();
		$updateOp = $condbM->getQuery($changePinStatusquery);
		$condbM->close();
	}
	
	//validation of login pages
	function validate($pin)
	{
		$condbM = $this->getConnectionObject();
		$status = 0;
		$validatequery = sprintf("select serialno, status, used from Library where pin = sha1('%s')", $pin);
		//call the getQuery method
		$rset = $condbM->getQuery($validatequery);
		if ($condbM->getNumRows() == 1){
			while (list($sn, $st, $us) = $condbM->getResults() ){
				if ((strlen($sn) == 15) and ($us == 'false') and ($st != 0)){
					$status = $st;
				}
				break;
			}	
		}
		$condbM->close();
		return $status;
	}
	
	//validation of login pages
	function getSectorNamebyId($id)
	{
		$condbM = $this->getConnectionObject();
		$sector = '';
		$getsectornamebyidquery ="SELECT sector FROM Sectortable where id = " . $id;
		//call the getQuery method
		$rset = $condbM->getQuery($getsectornamebyidquery);
		while ($rs = $condbM->getResults())
		{
			$sector = $rs['sector'];
		}
		$condbM->close();
		return $sector;
	}
	
	//fectes a reference to the DBconnection class
	function getConnectionObject(){
		$con = new Dbconnection($host, $user, $password,$db, "Y");
		//return the object
		return $con;
	}
	
	function getStateNameById($id)
	{
		$returnValue = '';
		$condbM = $this->getConnectionObject();
		$statequery = 'select state from tblstatetable where id = ' . $id;
		//call the getQuery method
		$rset = $condbM->getQuery($getsectornamebyidquery);
		while ($rs = $condbM->getResults())
		{
			$returnValue = $rs['state'];
		}
		$condbM->close();
		return $returnValue;
	}
}
?>
what is wrong with this pattern?

Michael