Location: PHPKode > scripts > qAdmin > jonathan-fielding-qAdmin-04ccc6a/classes/opendb.class.php
<?php

//
// Name: Database Connection
// Decription: Class to handle the database connections of the web application.
// Author: Jonathan Fielding
// 

class database_connection
{
	public $dbconnection;
	public $error_message = "";

    public function new_connection(){
    	include('config.php');
    	
		$con = mysql_connect($dbserver,$dbuser,$dbpass);
		
		if (!$con)
		{
			$this->error_message = 'Could not connect: ' . mysql_error();
		}
		else
		{
			$this->error_message = "none";
		}
		
		$this->dbconnection = mysql_select_db($database, $con);
		
	}
	
	public function check_connection(){
		
		$has_connection = false;
		
		if ($this->error_message == "none") {
				$has_connection = true;
		}
		
		return $has_connection;
	}
	
	public function dataquery($sql){
		$this->error_message = 'test';
		
		if ($this->check_connection() == false) {
			$this->new_connection();
		}
		
		if($this->error_message == "none"){
			$data = mysql_query($sql);
			$this->error_message = mysql_error();
			return $data;
		}
	}
	
}

?>
Return current item: qAdmin