You're calling mysqli_real_escape_string inside a function, and
$KCC
is out of scope there
$KCC
is out of scope there