<?php
include "application/scripts/connect.php";

/*
$hostname;
$username;
$password;
$database;
$dbdriver;
*/





function get_comment($session,$exam_id,$student_id){
define('BASEPATH', "/smartsms/");
define('ENVIRONMENT', "production");
//include "/smartsms/application/config/database.php";
//include "student_exam.php";
include "application/config/database.php";

$hostname = $db['default']['hostname'];
$username = $db['default']['username'];
$password = $db['default']['password'];
$database = $db['default']['database'];
$dbdriver = $db['default']['dbdriver'];

$database2 = 27686;

// Create connection
$conn_db = mysqli_connect($hostname, $username, $password, $database);
// Check connection
if (!$conn_db) {
    die("Connection failed: " . mysqli_connect_error());
}

//	$database2 = $GLOBAL['database2'];
	
//	global $conn_db;
	//global $database2;
	/*
		$sql3 = "INSERT INTO `exam_results_comment` (`session`, `exam_id`, `student_id`)
		VALUES ('$session', '$exam_id', '$student_id');";
		$query3 = mysqli_query($conn_db, $sql3);

	*/	
	$sql2 = "SELECT * from `exam_results_comment` WHERE session='$session' AND exam_id='$exam_id' AND student_id='$student_id';";

	if ($query2 = mysqli_query($conn_db, $sql2)) {
		if(mysqli_num_rows($query2) == 0){
		$sql3 = "INSERT INTO `exam_results_comment` (`session`, `exam_id`, `student_id`)
		VALUES ('$session', '$exam_id', '$student_id');";
		$query3 = mysqli_query($conn_db, $sql3);
		return "inserted";
		}
		else {
			return "insert failed" . $sql3;
		}
		//	return	echo "New record input made";
	} else {
		//return "failed again" . $sql2 . mysqli_error($conn_db);
		return 76588;
	}
}




?>  