There are many options.
You could use your current code and fetch the array as you are now and use the result properly, ie
$stud_id['student_id']
EDIT - try this
$value = mysql_query("SELECT max(student_id) AS StudId FROM student_profile");
$qryResultArray = mysql_fetch_array($value);
$stud_id = $qryResultArray['StudId'];
mysql_query("INSERT INTO course_batch (student_id, course_id, batch_id)
VALUES('$stud_id','$course_id','$batch_id')") or die (mysql_error());
if you specifically need to use commit (for whatever reason, you have other code I cannot see etc) then let me know.
The above is very basic too, it's not checking things are arrays, if there is a result, and has no security at all so sql injection is not protected (but then this code wont work soon anyway, when servers update their PHP)
Or you could greatly increase your security and usability and future proof your code by using mysqli or PDO, both of which while a learning curve are fairly easy to learn, and once learned no harder than what you are coding now.
The functions you use now will soon cause you issues and the need to check the PHP version on a server before your code can work (which is not ideal in any scenario)
very basic PDO example:
$db = new PDO(details here);
$stmt = $db->query('select id from student_profile etc');
$stud_id = $stmt->fetchColumn(0);
//then use $stud_id in your update/insert/etc
you then just check if the result is false (among other sanity checking to ensure your code is clean and all outcomes are accounted for)
You can use "order by limit 1", or "max, whatever