Thanks it helps a bit though still haven't quite grasped. Tried making the original array variable have the $ instead of after the fact and using the mysql escape but still get the variable name $rel_student_uid instead of the actual uid.
INSERT INTO tbl_detentions (rel_student_uid, detention_date) VALUES ('$rel_student_uid', '2013-3-3')
$database_info = array("db_table_name" => tbl_detentions, "db_field_names" => array("rel_student_uid", "detention_date"), "form_fields" => array('$rel_student_uid', "$detention_date"));
// Add detention to database BEGIN
$testt = mysql_real_escape_string($database_info['form_fields'][0]);
$query = "INSERT INTO ". $database_info['db_table_name'];
$query .= " (" . $database_info['db_field_names'][0] . ", " . $database_info['db_field_names'][1] . ") VALUES ";
$query .= "('" . mysql_real_escape_string($testt) . "', '$detention_date')";
$message .= $query;
$result = mysql_query($query);
if($result) {
$message .= "<center>Student given detention.</center>";
} else {
$message .= "Problem adding detention to student record.";
$message .= "<br>" . $query;
}
$detention_count++;
}
// Add detention to database END