I have absolutly no idea what this error means or what it requires me to do but i'm getting this error message:

Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required 'DOC__ROOT/library/classes/class_dao.php' (include_path='C:\Program Files\Zend\ZendStudio-5.5.1\bin\ZendFramework\library') in C:\xampp\htdocs\capat\library\classes\class_engcis.php on line 18

this is class_engcis.php

<?php

/**
 * 
 * engCIS local version
 * 
 */
 function & rel($struc, &$file) {
 	return file_exists( ( $file = ( dirname($struc).'/'.$file ) ) );
 }
 
 function relativetome($structure, $filetoget){
 	return rel($structure,$filetoget) ? require_once($filetoget) : null;
 }
 
relativetome(__FILE__, 'inc_global.php');

require_once(DOC__ROOT . '/library/classes/class_dao.php');
require_once(DOC__ROOT . '/library/functions/lib_array_functions.php');


class EngCIS {
	// Public Vars

	
	// Private Vars
	private $_DAO = null;
	private $_ordering_types = null;
	
	/**
	* CONSTRUCTOR
	*/
	function EngCIS() {
		$this->_DAO = new DAO(APP__DB_HOST,APP__DB_DATABASE,APP__DB_PASSWORD,APP__DB_DATABASE);
		$this->_DAO->set_debug(false);
	}// /->EngCIS()


/*
* ================================================================================
* Public Methods
* ================================================================================
*/


/*
* --------------------------------------------------------------------------------
* Course Methods
* --------------------------------------------------------------------------------
*/


	/**
	* Get array of courses for a department
	* @param string $department_id	ID of department to search
	* @param string $ordering	 ordering mode
	* @return array
	*/
/**	function get_department_courses($department_id, $ordering = 'name') {
		$order_by_clause = $this->_order_by_clause('course', $ordering);

		return $this->_DAO->fetch(	"
			SELECT lcc.*
			FROM live_cis_course lcc
			WHERE department_id='$department_id'
			$order_by_clause
		");
	}// /->get_department_courses()
*/

	/**
	* Get course info as an array
	* @param integer $course_id
	* @return array
	*/
/**	function get_course($course_id) {
		return $this->_DAO->fetch_row(	"SELECT lcc.*
										FROM live_cis_course lcc
										WHERE course_id='$course_id'
										");
	}// /->get_course()
*/

	/**
	* Get array of students for course
	*
	* @param string $ordering ordering mode
	*
	* @return array assoc-array of student info
	*/
/**	function get_course_students($course_id, $ordering = 'name') {
		$order_by_clause = $this->_order_by_clause('student', $ordering);

		return $this->_DAO->fetch(	"
																SELECT lcs.*
																FROM live_cis_student lcs INNER JOIN live_student_module lcsm ON lcs.student_id=lcsm.student_id AND module_id='$module_id'
																WHERE course_id='$course_id'
																$order_by_clause
															");
	}// /->get_course_students()
*/

/*
* --------------------------------------------------------------------------------
* Module Methods
* --------------------------------------------------------------------------------
*/


	/**
	* Get module info as an array
	*
	* @param string/array $module_id module ID(s) to search for
	* @param string $ordering	ordering mode
	*
	* @return array  either an assoc-array of module info or an array of assoc-arrays, containing many modules' info
	*/
	function get_module($modules = null, $ordering = 'id') {
		$module_search = $this->_DAO->build_filter('module_code', (array) $modules);
		$order_by_clause = $this->_order_by_clause('module', $ordering);
	
		// If there's more than one module to search for, get all the rows
		if (is_array($modules)) {
			return $this->_DAO->fetch("SELECT lcm.module_code AS module_id, lcm.module_title
										FROM module lcm
										WHERE $module_search
										$order_by_clause");
		} else {	// else, just return one row
			if (!empty($modules)) {
				return $this->_DAO->fetch_row("SELECT lcm.module_code AS module_id, lcm.module_title
												FROM module lcm
												WHERE $module_search
												LIMIT 1");
			}
		}
	}// /->get_module()

	
	/**
	* Get array of staff for module
	* @param integer $module_id
	* @param string $ordering
	* @return array
	*/
	function get_module_staff($module_id, $ordering) {
		$order_by_clause = $this->_order_by_clause('staff', $ordering);

		return $this->_DAO->fetch	("SELECT lcs.*
									FROM user lcs 
									INNER JOIN user_module lcsm ON lcs.user_id = lcsm.user_id
									WHERE lcs.user_type = 'staff'
										AND module_id='$module_id'
									$order_by_clause");
	}// /->get_module_staff()


	/**
	* Get array of students for one or more modules
	* @param integer $modules
	* @param string $ordering
	* @return array
	*/
	function get_module_students($modules, $ordering = 'name') {
		$module_set = $this->_DAO->build_set($modules);
		$order_by_clause = $this->_order_by_clause('student', $ordering);
		
		return $this->_DAO->fetch("	SELECT DISTINCT lcs.*, lcs.lastname AS surname, institutional_reference AS student_id
									FROM user lcs
									INNER JOIN user_module lcsm ON lcs.user_id=lcsm.user_id AND module_id IN $module_set
									WHERE lcs.user_type = 'student'
									$order_by_clause
									");
	}// /->get_module_students()

	
	/**
	* Get total number of students on one or more modules
	*
	* @param array $modules	 modules to count students for
	* @return array
	*/
	function get_module_students_count($modules) {
		$module_set = $this->_DAO->build_set($modules);
		
		$sql = "SELECT COUNT(DISTINCT u.user_id)
				FROM user u
  					INNER JOIN user_module um ON u.user_id=um.user_id
  					INNER JOIN module m ON m.module_code=um.module_id
				WHERE m.module_code IN $module_set
					AND u.user_type = 'student'";
		return $this->_DAO->fetch_value($sql);
	}// /->get_module_students_count


	/**
	* Get an array of student IDs for students on the given modules
	* @param array $modules	 modules to count students for
	* @return array
	*/
	function get_module_students_id($modules) {
		if (!empty($modules)) {
			$module_set = $this->_DAO->build_set( (array) $modules);
			return $this->_DAO->fetch_col("SELECT DISTINCT u.institutional_reference AS staff_id
											FROM user u
											INNER JOIN user_module um ON u.user_id=um.user_id
											INNER JOIN module m ON m.module_code=um.module_id
											WHERE m.module_code IN $module_set
												AND u.user_type = 'student'
											ORDER BY u.user_id ASC");
		}
	}// /->get_module_students_id()
	
	
	/**
	* Get an array of user IDs for students on the given modules (user_id = 'student_{studentID}'
	* @param array $modules	 modules to count students for
	* @return array
	*/
	function get_module_students_user_id($modules) {
		if (!empty($modules)) {
			$module_set = $this->_DAO->build_set( (array) $modules);
			$sql = "SELECT DISTINCT u.user_id
					FROM user u
						INNER JOIN user_module um ON u.user_id=um.user_id
						INNER JOIN module m ON m.module_code=um.module_id
					WHERE m.module_code IN $module_set
						AND u.user_type = 'student'
					ORDER BY u.user_id ASC
					";
			return $this->_DAO->fetch_col($sql);
		}
	}// /->get_module_students_user_id()


	/**
	* Get number of students on individual multiple modules, grouped by module
	*
	* @param array  $modules	modules to count students for
	* @return array 
	*/
	function get_module_grouped_students_count($modules) {
		$module_search = $this->_DAO->build_filter('module_id', (array) $modules, 'OR');

		return $this->_DAO->fetch_assoc("SELECT module_id, COUNT(user_id)
										FROM user_module lcsm
										WHERE $module_search
										GROUP BY module_id
										ORDER BY module_id");
	}// ->get_modules_grouped_students_count()


/*
* --------------------------------------------------------------------------------
* Staff Methods
* --------------------------------------------------------------------------------
*/

	
	/**
	* Get staff info
	* Can work with either staff_id or staff_username alone (staff_id takes precedent)
	*
	* @param string/array $staff_id	 staff ID(s) to search for (use NULL if searching on username)
	* @param string/array $staff_username	 staff username(s) to search for
	* @param string $ordering ordering mode
	*
	* @return array either an assoc-array of staff member info or an array of assoc-arrays, containting many staff members' info
	*/
	function get_staff($staff_id, $staff_username = null, $ordering = 'name') {
		if ($staff_id) {
			$staff_set = $this->_DAO->build_set($staff_id);
			$sql_WHERE = "user_id IN $staff_set ";
		}	else {
			if ($staff_username) {
				$staff_set = $this->_DAO->build_set($staff_username);
				$sql_WHERE = "username IN $staff_set ";
			}	else { return null; }
		}

		$order_by_clause = $this->_order_by_clause('staff', $ordering);
		
		// If there's more than one staff member to search for, get all the rows
		if ( (is_array($staff_id)) || (is_array($staff_username)) ) {
			return $this->_DAO->fetch("SELECT lcs.*, lcs.lastname AS surname, institutional_reference AS staff_id
										FROM user lcs
										WHERE $sql_WHERE
										$order_by_clause");
		} else {	// else, just return one row
			return $this->_DAO->fetch_row("SELECT lcs.*, lcs.lastname AS surname, institutional_reference AS staff_id
											FROM user lcs
											WHERE $sql_WHERE
											LIMIT 1");
		}
	}// /->get_staff()


	/**
	* Get array of modules for the given staff member(s)
	* Can work with either staff_id or staff_username alone (staff_id takes precedent)
	*
	* @param string/array $staff_id	staff ID(s) to search for (use NULL if searching on username)
	* @param string/array $staff_username	staff username(s) to search for
	* @param string $ordering	ordering mode
	*
	* @return array	 an array of assoc-arrays, containting many module info
	*/
	function get_staff_modules($staff_id, $staff_username = null, $ordering = 'id') {
		if ($staff_id) {
			$staff_set = $this->_DAO->build_set($staff_id);
			$sql_WHERE = "user_id IN $staff_set ";
		}	else {
			if ($staff_username) {
				$staff_set = $this->_DAO->build_set($staff_username);
				$sql_WHERE = "username IN $staff_set ";
			}	else { return null; }
		}
		
		$order_by_clause = $this->_order_by_clause('module', $ordering);
		
		return $this->_DAO->fetch(	"SELECT DISTINCT lcm.module_code AS module_id, lcm.module_title
									FROM module lcm INNER JOIN user_module lcsm ON lcm.module_code=lcsm.module_id
									WHERE $sql_WHERE
									$order_by_clause");
	}// /->get_staff_modules


	/**
	* Is the given staff member associated with the given modules?
	*
	* @param string $staff_id staff id of member being checked
	* @param string/array $module_id	either a single module_id, or an array of module_ids
	* @return integer
	*/
	function staff_has_module($staff_id, $module_id) {
		$module_id = (array) $module_id;
		$staff_modules = $this->get_staff_modules($staff_id);
		if (!$staff_modules) {
			return false;
		} else {
			$arr_module_id = array_extract_column($staff_modules, 'module_id');
			$diff = array_diff($module_id, $arr_module_id);
			
			// If the array is empty, then the staff member has those modules
			return (count(array_diff($module_id, $arr_module_id))===0);  
		}
	}// /->staff_has_module()

	
/*
* --------------------------------------------------------------------------------
* Student Methods
* --------------------------------------------------------------------------------
*/


	/**
	* Get student info
	* Can work with either student_id or student_username alone (student_id takes precedent)
	*
	* @param string/array $student_id	 student ID(s) to search for (use NULL if searching on username)
	* @param string/array $student_username	 student
	* @param string $ordering	 ordering mode
	*
	* @returns	array either an assoc-array of student info	or an array of assoc-arrays, containting many students info
	*/
	function get_student($student_id = null, $student_username = null, $ordering = 'name') {
		if ($student_id) {
			$student_set = $this->_DAO->build_set($student_id);
			$sql_WHERE = "user_id IN $student_set ";
		}	else {
			if ($student_username) {
				$student_set = $this->_DAO->build_set($student_username);
				$sql_WHERE = "username IN $student_set ";
			}	else { return null; }
		}
		
		// If there's more than one student to search for, get all the rows
		if ( (is_array($student_id)) || (is_array($student_username)) ) {
			$order_by_clause = $this->_order_by_clause('student', $ordering);
			return $this->_DAO->fetch("SELECT lcs.*, lcs.lastname AS surname, institutional_reference AS student_id
										FROM user lcs
										WHERE $sql_WHERE
										$order_by_clause");
		} else {	// else, just return one row
			return $this->_DAO->fetch_row("SELECT lcs.*, lcs.lastname AS surname, institutional_reference AS student_id
											FROM user lcs
											WHERE $sql_WHERE
											LIMIT 1");
		}
	}// /->get_student()


	/**
	* Get array of modules for the given student(s)
	* Can work with either student_id or student_username alone (student_id takes precedent)
	*
	* @param string/array $student_id	student ID(s) to search for (use NULL if searching on username)
	* @param string/array $student_username	student username(s) to search for
	* @param string $ordering	ordering mode
	*
	* @return array an array of module info arrays
	*/
	function get_student_modules($student_id, $student_username = null, $ordering = 'id') {
		if ($student_id) {
			$student_set = $this->_DAO->build_set($student_id);
			$sql_WHERE = "user_id IN $student_set ";
		}	else {
			if ($student_username) {
				$student_set = $this->_DAO->build_set($student_username);
				$sql_WHERE = "username IN $student_set ";
			}	else { return null; }
		}
		
		$order_by_clause = $this->_order_by_clause('module', $ordering);
		
		return $this->_DAO->fetch(	"SELECT DISTINCT lcm.module_code AS module_id, lcm.module_title
									FROM module lcm INNER JOIN user_module lcsm ON lcm.module_code=lcsm.module_id
									WHERE $sql_WHERE
									$order_by_clause");
	}// /->get_student_modules()


/*
* --------------------------------------------------------------------------------
* User Methods
* --------------------------------------------------------------------------------
*/


	/**
	* Get a user's info
	*
	* @param string/array $user_id user ID(s) to search for
	* $ordering	: (string) - ordering mode
	*
	* Returns	: either an assoc-array of user info
	*						or an array of assoc-arrays, containting many users' info
	*/
	function get_user($user_id, $ordering = 'name') {
		$user_set = $this->_DAO->build_set($user_id);
		$sql_WHERE = "user_id IN $user_set ";
		
		
		// If there's more than one user to search for, get all the rows
		if (is_array($user_id)) {
			$order_by_clause = $this->_order_by_clause('user', $ordering);
			$sql = "SELECT scu.*, scu.lastname AS surname
					FROM user scu
					WHERE $sql_WHERE
					$order_by_clause";
					
			return $this->_DAO->fetch($sql);
		} else {	// else, just return one row
			$sql = "SELECT scu.*, scu.lastname AS surname
					FROM user scu
					WHERE $sql_WHERE
					LIMIT 1";
			return $this->_DAO->fetch_row($sql);
		}
	}// /->get_user()
	
	
	
	/**
	* Get a user's info by searching on email address
	*
	* @param string $email email address to search for
	*
	* Returns	: an assoc-array of user info
	*/
	function get_user_for_email($email) {
		return $this->_DAO->fetch_row("SELECT scu.*
									   FROM user scu
									   WHERE email='$email'
									   LIMIT 1");
	}// /->get_user_for_email()
	
	

	
/*
* ================================================================================
* Private Methods
* ================================================================================
*/


	/**
	* Return an ORDER BY clause matching the given parameters
	*
	* @param string $row_type type of row being ordered. ['course','module','staff','student']
	* @param string $ordering	 type of ordering to do. ['id','name']
	*
	* @return	string	SQL ORDER BY clause of the form 'ORDER BY fieldname' or NULL if row_type/ordering are invalid
	*/
	function _order_by_clause($row_type, $ordering = null) {
		if (!is_array($this->_ordering_types)) {
			// All available ordering types
			$this->_ordering_types = array (
/**				'course'	=> array	(
									'id'	=> 'lcc.course_id' ,
									'name'	=> 'lcc.course_title' ,
								) ,
*/
				'module'	=> array	(
									'id'	=> 'lcm.module_id' ,
									'name'	=> 'lcm.module_title' ,
								) ,
				'staff'		=> array	(
									'id'	=> 'lcs.user_id' ,
									'name'	=> 'lcs.lastname, lcs.forename' ,
								) ,
				'student'	=> array	(
									'id'	=> 'lcs.user_id' ,
									'name'	=> 'lcs.lastname, lcs.forename' ,
								) ,
				'user'		=> array	(
									'id'	=> 'scu.user_id' ,
									'name'	=> 'scu.lastname, scu.forename' ,
								) ,
			);
		}

		if ( (array_key_exists($row_type, $this->_ordering_types)) && (array_key_exists($ordering, $this->_ordering_types["$row_type"])) ) {
			return 'ORDER BY '. $this->_ordering_types["$row_type"]["$ordering"];
		} else {
			return null;
		}
	}// /->_order_by_clause()


}// /class: EngCIS

?>

unless i am totally mistaken it looks like the include file is missing

dami, you are getting this error because DOC__ROOT is an undefined constant. This was also happening in the code you sent me.

Try changing the required() calls from this:

require_once(DOC__ROOT . '/library/classes/class_dao.php');

to this:

require_once($_SERVER . '/library/classes/class_dao.php');

If this doesn't work, then your DocumentRoot path has not been set.

hi richie, i changed the require_once to the one you said i should do but i got this error message


Notice: Only variable references should be returned by reference in C:\xampp\htdocs\capat\library\classes\class_engcis.php on line 9

Warning: require_once(C:/xampp/htdocs/library/classes/class_dao.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\capat\library\classes\class_engcis.php on line 18

Fatal error: require_once() [function.require]: Failed opening required 'C:/xampp/htdocs/library/classes/class_dao.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\capat\library\classes\class_engcis.php on line 18

Hi dami,

Make sure those files exist and if they do, then they should be in those folders for them to be required.

hi richie,
those files exist and they are in the same folder. I will put the code of that file for you to look at. It's stil giving me that error message.

class_dao.php

<?php
/**
 * 
 * Class : DAO
 * 	
 * This data access object is designed for MySQL only
 *
 * 
 * Updates:
 * 18-07-2007   : improved ->_throw_error() code
 * 13-07-2005	: added ->build_set() method - returns a string containing an SQL set
 * 12-07-2005	: added ->get_num_cols() method - returns the number of column names
 * 12-07-2005	: added ->get_cols() method - returns an array of column names
 * 16-06-2005	: fixed a bug when using NULL values in do_insert/do_update
 * 14-06-2005	: added $new_link parameter to ->open() method
 * 13-06-2005	: added ->do_insert_multi() method for adding multiple rows in one statement
 * 09-06-2005	: fixed potential insert-id bug
 * 15-10-2004	: new ->fetch_assoc() method - gets the query as an associative array
 *				  of the form:  array ( row1.field1 => row1.field2, ... ) 
 * 31-09-2004	: Fixed multi-database usage (stops connection clashing)
 * 
 */


class DAO {
	// Public Vars

	// Private Vars
	private $_host = 'localhost';				// DB Connection info
	private $_user = '';
	private $_password = '';
	private $_database = 'pa';
	private $_persistent = false;

	private $_conn = null;				// DB Connection object

	private $_result_set = null;		// Contains the result set (temporarily)
	private $_result_cols	= null;		// Array of columns for the result set

	private $_last_sql = null;			// Last query run
	private $_result = null;			// Query results, as array of row objects

	private $_output_type = 'ARRAY_A';	// 'ARRAY_A': Associative Array	: $results[row]['field']
										// 'ARRAY_N': Numeric Array	: $results[row][col]
										// 'ARRAY_B': Assoc + Numeric Array	: use $results[row]['field'] or $results[row][col]

	private $_output_type_int = MYSQL_ASSOC;	// MYSQL_ASSOC, MYSQL_BOTH, MYSQL_NUM
	
	private $_insert_id = null;			// Last inserted id (on auto-increment columns)
	
	private $_num_cols = null;
  	private $_num_rows = null;
  	private $_num_affected = null;
	
	private	$_debug = false;			// debug mode (default: off)
	private $_last_error = null;


   /**
	* CONSTRUCTOR
  	* Set database connection strings
  	* @param string $host
  	* @param string $user
  	* @param string $password
  	* @param string $database
  	* @param boolean $persistent
	*/
	function DAO($host, $user, $password, $database, $persistent = false) {
		$this->_host = $host;
		$this->_user = $user;
		$this->_password = $password;
		$this->_database = $database;
		$this->_persistent = $persistent;
	} // /DAO()

  
/*
* ================================================================================
* Public Methods
* ================================================================================
*/


	/**
	* Open database connection
	* @param boolean $new_link	 block reusing an existing database connection when the same server/username/password are used
	* @return boolean
	*/
	function open($new_link = true) {
		if (is_null($this->_conn)) {
			if ($this->_persistent) {
				$func = 'mysql_pconnect';
			} else {
				$func = 'mysql_connect';
			}

			if ($this->_debug) {
				$this->_conn = @$func($this->_host, $this->_user, $this->_password, $new_link) or $this->_throw_error('Connecting to server');
				@mysql_select_db($this->_database, $this->_conn) or $this->_throw_error('Selecting Database');
			} else {
				$this->_conn = @$func($this->_host, $this->_user, $this->_password, $new_link);
				if(@!mysql_select_db($this->_database, $this->_conn)) {
					return false;
				}
			}
 		}
		return true;
	} // /->open()

/**
 * Close database connection
 * @return object
 */
	function close() {
  	$this->flush();
		return ( @mysql_close($this->_conn) );
	} // /->close()

  
	/** 
	 * Clear results and reset result vars
	 */
	function flush() {
    $this->_result = null;
		$this->_num_rows = null;
		$this->_num_affected = null;
    $this->_insert_id = null;
	} // /->flush()

  
	/**
	* Execute the SQL query, and ignore results (ie, not a SELECT)
	* Sets affected rows (ie could be DELETE/INSERT/REPLACE/UPDATE)
	* Sets inserted id if query is INSERT/REPLACE	(checks first word of query)
	* @param string $sql
	* @return boolean
	*/
  function execute($sql) {
  	$this->flush();
		$this->open();
  	$this->_last_sql = trim( $sql );	// Save query

		if ($this->_debug) {
			$this->_result_set = mysql_query($sql, $this->_conn) or $this->_throw_error('Executing SQL');
		} else {
	 		$this->_result_set = @mysql_query($sql, $this->_conn);
		}

		if ($this->_result_set) {
			$this->_num_affected = mysql_affected_rows($this->_conn);
    
  	  if ( preg_match("/^\\s*(insert|replace) /i", $sql) ) {
    		$this->_insert_id = mysql_insert_id($this->_conn);
	    }
    
  	  if ($this->_num_affected) {
    		return true;
	    } else {
  	  	return false;
    	}
		} else {
    	return false;
    }
  }// /->execute()


	/**
	* Get results of the given query
	* @param string $sql
	* @return object
	*/
	function fetch($sql = null) {
			// If there is an SQL query, get its results instead..
		if ( $sql ) { $this->_process_query($sql); }

		return $this->_result;
	} // /->fetch()


	/**
	* Get a single row (of the given query or cache)
	* Row indexes are 0-based
	* @param string $sql
	* @param integer $y
	* @return object
	*/
  function fetch_row($sql = null, $y = 0) {
		// If there is an SQL query, get its results instead..
  	if ( $sql ) { $this->_process_query($sql);	}
		return (isset($this->_result)) ? $this->_result[$y] : null;
	}	// /->fetch_row()


	/**
	* Get a single column as a numeric array
	* column indexes are 0-based
	* @param string $sql
	* @param integer $x
	* @return array
	*/
 	function fetch_col($sql = null, $x = 0)	{
		// If there is an SQL query, get its results instead..
		if ( $sql ) { $this->_process_query($sql);	}

		$new_array = null;
		
		// Extract the column value
		if ($this->_num_rows>0) {
			for ( $i=0; $i<$this->_num_rows; $i++ ) {
				$new_array[$i] = $this->fetch_value(null,$x,$i);
			}
		}
		return $new_array;
	}	// /->fetch_col()


	/**
	* Get a single value from the result set
    * column/row indexes are 0-based
	* An empty string ('') or no value, will return null
	* @param string $sql
	* @param integer $x
	* @param integer $y
	* @return integer
	*/
 	function fetch_value($sql = null, $x = 0, $y = 0) {
		// If there is an SQL query, get its results instead..
		if ( $sql ) { $this->_process_query($sql);	}

  	// Extract value using x,y vals
  	if ( $this->_result[$y] )	{
  		$values = array_values($this->_result[$y]);
  	}
  	// If there is a value return it, else return null
  	return ( isset($values[$x]) && $values[$x]!=='') ? $values[$x] : null;
	} // /->fetch_value()

	
	/**
	* Get an associative array ( field1-value => field2-value ) from the result set
	* If you retrieve more than 2 fields, you will get an associative array of row-arrays
	* e.g.   field1-value => array ( field2 => field2-value, field3 => field3-value, ... ), ...
	* @param string $sql
	* @return array
	*/
	function fetch_assoc($sql = null) {
		// Need to be in Numeric+Assoc Array mode, so set it
		$original_output_mode = $this->get_output_mode();
		$this->set_output($output = 'ARRAY_B');

		// Fetch the new result set
		$this->_process_query($sql);
		
		// Reset mode to what it was before
		$this->set_output($original_output_mode);
		
		$new_array = null;

		if ($this->_num_rows>0) {		
			if ($this->get_num_cols()==2) {
				// Convert rows to simple associative array
				for ( $i=0; $i<$this->_num_rows; $i++ ) {
					$new_array["{$this->_result[$i][0]}"] = $this->_result[$i][1];
				}
			} else {
				// Convert rows to associative array of arrays
				for ( $i=0; $i<$this->_num_rows; $i++ ) {
					$row_array = null;
					for ( $j=1; $j<$this->_num_cols; $j++ ) {
						$row_array[$this->_result_cols["$j"]] = $this->_result[$i][$j];
					}
					$new_array["{$this->_result[$i][0]}"] = $row_array;
				}
			}
		}
		return $new_array;
	}// /->fetch_assoc()
	

	/**
	*	Execute the insert query in $sql, using the fields in $fields
	*	auto-slashes the given fields
	* @param string $sql string of the form 'INSERT INTO tbl_name ({fields}) VALUES ({values}) '
	* @param array $fields	 array ( fieldname1 => ???, fieldname2 => ???, ... )
	*/
	function do_insert($sql, $fields) {
		$fields_str = implode(',', (array) array_keys($fields) );

		$values = array();
 		foreach ($fields as $k => $v) {
			$values[] = $this->_prepare_field_value($v);
 		}
		$values_str = implode(',',$values);

		$sql = str_replace('{fields}',$fields_str,$sql);
		$sql = str_replace('{values}',$values_str,$sql);
		return $this->execute($sql);
	} // /->do_insert()
	
	
	/**
	* Execute the insert query in $sql, using multiple VALUES statements as given in $fields
	* Auto-slashes the given fields
	*
	* NOTE	: Unlike ->do_insert, the $fields array is an array[0..n] of assoc-arrays
	* NOTE	: Only the last insert-id will be available from ->get_insert_id() following execution
	* 
	* @param string $sql of the form, 'INSERT INTO tbl_name ({fields}) VALUES {values}
	* @param array $fields array[0..n] of array ( fieldname1 -> ???, fieldname2 => ???, ... )
	* @return object
	*/
	function do_insert_multi($sql, $fields) {
		if (is_array($fields)) {
			$fields_str = implode(',', array_keys($fields[0]) );
		
			$value_row = null;
		
			foreach ($fields as $i => $row) {
				$value_row["$i"] = array ();
				foreach($row as $k => $v) {
					$value_row["$i"][] = $this->_prepare_field_value($v);
				}
				$value_row["$i"] = '('. implode(',',$value_row["$i"]) .')';
			}
			$values_str = implode(',',$value_row);

			$sql = str_replace('{fields}',$fields_str,$sql);
			$sql = str_replace('{values}',$values_str,$sql);

			return $this->execute($sql);
		} else {
			return null;
		}
	}// /->do_insert_multi()
  
	
	/**
	*	Execute the update query in $sql, setting the fields in $fields
	*	Auto-slashes the given fields
	*	@param string $sql  sql query of the form  'UPDATE tbl_name SET {fields} WHERE xxx=yyy'
	*	@param array $fields of fields and values to set - of the form  array ( fieldname1 => ???, fieldname2 => ???, ... )
	*	@return mixed
	*/
	function do_update($sql, $fields) {
		$set_str = '';
		$fields_count = count($fields);
		$i=1;
		
		foreach ($fields AS $k=>$v) {
			$set_str .= " $k=". $this->_prepare_field_value($v);
			if ($i<$fields_count) { $set_str .= ','; }
			++$i;
		}

		$sql = str_replace('{fields}',$set_str,$sql);
		return $this->execute($sql);
	} // /->do_update()
	
	
	/**
	* Builds filter clause of the form  (aaa='bbb' OR aaa='ccc' OR aaa='ddd' ... )
	*
	* @param string $field_name the field name being checked (aaa in example above)
	* @param array/value $filter_values the values to compare against.
	* @param string $logical_operator the operator to use to concatenate the filters (AND, OR, XOR)
	* @return string
	*/
	function build_filter($field_name, $filter_values, $logical_operator = 'OR') {
		$filter_values = (array) $filter_values;	// cast values to array (in case it was only passed one)

		$filter_clause = '(';
		$w_count = count($filter_values);
		$i = 1;
		foreach($filter_values as $k => $v) {
			$v = $this->escape_str($v);
			$filter_clause .= "$field_name=". $this->_prepare_field_value($v);
			if ($i<$w_count) { $filter_clause .= " $logical_operator "; }
			$i++;
		}
		$filter_clause .= ')';

		return $filter_clause;
	}// ->build_filter()

	
	/**
	* Builds an SQL set of the form  ('aaa','bbb','ccc') for use with IN operators
	*
	* @param array/value $value_array	array of values to include in the set
	* @return string
	*/
	function build_set($value_array) {
		$value_array = array_map('addslashes',(array) $value_array);
		return '(\''. implode('\',\'',$value_array) .'\')';
	}// /->build_set()
	
	
/*
* --------------------------------------------------------------------------------
* Accessor Methods
* --------------------------------------------------------------------------------
*/

	// GET_xxx functions
	
  /**
   * Return an array of columns names from the last query
   * @return boolean 
   */
	function get_cols() { return (is_array($this->_result_cols)) ? $this->_result_cols : null ; }

	
  /**
   * Return the number of columns from the last query
   * @return integer
   */
	function get_num_cols() { return $this->_num_cols; }

	
  /**
   * Return the number of rows from the last query
   * @return integer
   */
	function get_num_rows() { return $this->_num_rows; }

  
  /**
   * Return the number of affected rows from the last query (insert/replace/update)
   * @return integer
   */
	function get_num_affected() { return $this->_num_affected; }


 /** 
  * Return last inserted id (for auto-increment columns)
  * @return integer 
  */
  function get_insert_id() { return $this->_insert_id; }

	
 /** 
  * Return last run query
  * @return string
  */
  function get_last_sql() { return $this->_last_sql; }


/**
 *  Get last mysql error
 */	
	function get_last_error() { mysql_error($this->_conn); }


	/**
	 * Get output mode
	 * @return mixed 
	 */
	function get_output_mode() { return $this->_output_type; }


/*
* --------------------------------------------------------------------------------
* SET_xxx functions
* --------------------------------------------------------------------------------
*/

	/**
	* Set debug mode
	* When in debug mode, detailed error reports are echoed
	* @param boolean 
	*/
	function set_debug($on) {
		$this->_debug = $on;
	}
	
	
	/**
	* Set default output mode for results array
	* @param string $output
	* @return boolean
	*/
	function set_output($output = 'ARRAY_A') {
		switch ($output) {
			case 'ARRAY_A'	:
						$this->_output_type_int = MYSQL_ASSOC;
						$this->_output_type = $output;
						return true;
						break;
			// ----------------------------------------
			case 'ARRAY_B'	:
						$this->_output_type_int = MYSQL_BOTH;
						$this->_output_type = $output;
						return true;
						break;
			// ----------------------------------------
			case 'ARRAY_N'	:
						$this->_output_type_int = MYSQL_NUM;
						$this->_output_type = $output;
						return true;
						break;
			// ----------------------------------------
			default :
				return false;
				break;
		}
	}// /->set_output()


  /** 
   * Escape character string
   * @param string $str
   * @return string 
   */
  function escape_str($str)	{	return mysql_escape_string(stripslashes($str)); }

	
/*
* ================================================================================
* Private Methods
* ================================================================================
*/
	

	/** 
	 * Execute the SQL and collect the result set
	 * @param string $sql
	 * @return boolean
	 */
	function _process_query($sql) {
  	$this->flush();
		$this->open();
  	$this->_last_sql = trim( $sql );	// Save query

		if ($this->_debug) {
			$this->_result_set = mysql_query($sql, $this->_conn) or $this->_throw_error('Querying database');
		} else {
	  	$this->_result_set = @mysql_query($sql, $this->_conn);
		}

		// If got a result set..	
		if ($this->_result_set) {

			// number of columns returned
			$this->_num_cols = mysql_num_fields($this->_result_set);

			// Store column names as an array
			$i=0;
			$this->_result_cols = array();
			while ($i < $this->_num_cols) {
				$field = @mysql_fetch_field($this->_result_set,$i);
				$this->_result_cols[] = $field->name;
				$i++;
			}
		
			// Store the results as an array of row objects
			while ( $row = @mysql_fetch_array($this->_result_set,$this->_output_type_int) ) {
				$this->_result[] = $row;
			}

			// number of rows returned
			$this->_num_rows = count($this->_result);

      // Free the actual result set
			@mysql_free_result($this->_result_set);

			// If there were results.. return true
			return ($this->_num_rows>=1);
		} else {
			$this->_num_cols = 0;
			$this->_num_rows = 0;
			$this->_result_cols = null;
    	return false;
    }
	} // /->process_query()

	/**
	 * function to capture the thrown error and out put to the screen
	 * @param string $err_msg
	 * @return boolean 
	 */
	function _throw_error($err_msg) {
		if ($this->_conn) {
			die("<hr />DATABASE ERROR<hr />$err_msg :: ". mysql_error($this->_conn) .'<hr />'. $this->get_last_sql().'<hr />');
		} else {
			die("<hr />DATABASE ERROR<hr />$err_msg :: &lt;NO SERVER&gt;<hr />". $this->get_last_sql().'<hr />');
		}
		return false;
	}// /->_throw_error()


	/**
	* Prepare a value for putting into the database
	* Escapes special characters, checks for NULL, and puts in quotes as necessary
	*
	* @param integer $value	value to prepare
	*
	* @return string   en-quoted value, ready for insertion into a database (of the form 'value' or NULL)
	*/
	function _prepare_field_value($value) {
		// NULL values don't need quotes, so if it's null, just return a string containing NULL
		// Else, return an escaped string containing the value enclosed in quotes
		return (is_null($value)) ? 'NULL' : '\''. $this->escape_str($value) .'\'';
	}// /->_prepare_field_value()


} // /class: DAO

?>

I never had all these errors before, i don't why i'm having them now

right what i have done now is to disable the error reporting and now i don't have that showing all over my screen but now i get this error message

?>
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\capat\include\classes\class_ui1.php:2) in C:\xampp\htdocs\capat\tutors\forms\create\class_wizardstep_2.php on line 70

what does this mean

Send me all of you code dami, I'll have a look:)

ok richie, im going to send the code to you now and let you know where the problem is..Please reply to me soon with solution as i need to hand this in by tuesday..thanks

As soon as I recieve I will have a look:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.