Your IP : 216.73.216.40


Current Path : /var/www/html/rkala/data/
Upload File :
Current File : /var/www/html/rkala/data/getdata.php

<?php
	include 'credential.php';
	mysql_connect($host, $user, $pass);
	mysql_select_db('proto_type');
?>

<?php
	$imagename=$_FILES["myimage"]["name"]; 
	$roll = $_POST["roll"];
	$question = $_POST["question"];

	//Get the content of the image and then add slashes to it 
	$imagetmp = addslashes (file_get_contents($_FILES['myimage']['tmp_name']));

	// fetch the current index of the database
	$insert_image="Select max(a_id) from answer";
	$result = mysql_query($insert_image);
	$row = mysql_fetch_array($result);
	$curr_index = $row[0] + 1;

	//Insert the image name and image content in image_table
	$insert_image="INSERT INTO answer (a_id, image) VALUES ('$curr_index','$imagetmp')";
	
	if(mysql_query($insert_image) or die(mysql_error())){
		$insert_image="INSERT INTO ques_stud_ans (stud_id, ques_id, ans_id) VALUES('$roll','$question','$curr_index')";
		if(mysql_query($insert_image)){
			echo "Success";
		}else{
			echo "Failed_second"; 
		}
	}else{
		echo "Failed";
	}

	/*
	echo $roll . "<br>";
	echo $curr_index . "<br>";
	echo $question . "<br>";
	*/

	/*if(mysql_query($insert_image)){
		echo "Success";
	}else{
		echo "Failed";
	}*/
?>