I'm gettin a fatal error trying to apply a function to the code
    $userId = $_SESSION['userSession'];
    $matrixid = $_POST['matrixid'];
 $sponsorId = trae_sponsor($userId);
 $id_matriz_sponsor = $get_sponsor_matrix_id($sponsorId,$matrixid); 
function get_sponsor_matrix_id($id_usuario,$tipo_Matriz){
 global $DBcon;
 $sql = $DBcon->query("SELECT id FROM users_matrices WHERE userId=$id_usuario AND matrixId=$tipo_Matriz AND completed=0");
 $row = $sql->fetch_array();
 $id_matriz_sponsor = $row['id'];
 return $id_matriz_sponsor;
 }
function trae_sponsor($id_usuario){
global $DBcon;
$Sql = $DBcon->query("SELECT sponsor_id from users_referrals WHERE referred_id='$id_usuario' ");
$row = $Sql->fetch_array();
$id = $row["sponsor_id"];
return $id;
}
Error says: " Undefined variable: get_sponsor_matrix_id in.....
Fatal error : Uncaught Error: Function name must be a string in.... "
I can't see the error so far. Thank you
 
     
    