调用其他函数PHP [关闭]

I have a file myfunctions.php which has four functions. all functions when called perform some transaction to database. if im calling only one function from that page that is working fine. but if im calling two functions than only one top one(function that is called first) is working and other are not working.

myfunctions.php

<?php

include('includes/db.inc.php');

function blockip($ip,$attempts){
    global $mysqli;
    if(isset($ip) && $ip!=''){
        $query = 'INSERT INTO blockip VALUES(?,?)';
        if($stmt = $mysqli -> prepare($query)){
            $stmt -> bind_param('si',$ip,$attempts);
            $stmt -> execute();
            $stmt -> close();
        }
        $mysqli -> close();
    }else{
        echo $mysqli-> error();
    }
}
function getip($ip){
    global $mysqli;
    $ip_found =  null;
    if(isset($ip) && $ip!=''){
        $query = 'SELECT `ip` FROM `blockip` WHERE `ip`=?';
        if($stmt=$mysqli -> prepare($query)){
            $stmt -> bind_param('s',$ip);
            $stmt -> execute();
            $stmt -> bind_result($ipret);
            $stmt -> fetch();
            $stmt -> close();
            if($ipret!=null)
                $ip_found = $ipret;
            else
                $ip_fount = '';
        }
        $mysqli -> close();
    }
    return $ip_found;
}
?>

other functions at this file are also using $mysqli by declaring it global and all are of similar nature.

file at which im calling these functions login.php

<?php
session_start();
include('myfunctions.php');
$client_ip = $_SERVER['REMOTE_ADDR'];
?>

<!DOCTYPE html>
<html>
     <!-- Some HTML Code HERE -->
</html>
<?php
if($_SESSION['errorcode']==1){
    echo '<center> Invalid Captcha </center>';
}elseif($_SESSION['errorcode']==2){
    echo '<center> Invalid UserName / Password Combination </center>';
    trygetip($client_ip);
}
if($_SESSION['errorcode']==3){
    session_destroy();
    header('Location: 403.html');
    exit();
}
?>

my database file db.inc.php

<?php
error_reporting(0);
$db="xxxxxx";
$host="xxxxxx";
$username="xxxx";
$password="xxxx";
$mysqli =  new mysqli($host,$username,$password,$db);
if($mysqli->connect_error){
    die('Connection Failed : '.$mysqli-> connect_errno.' : '.$mysqli -> connect_error);
}
?>

now if i use two functions getip($someiphere) and than bockip($someiphere,$attempts) than 2nd one is not working and same issue with if i replace their position. thanx in advance

You close the mysql connection in both functions, just omit the $mysqli -> close();.

its because you close $mysqli at the end of each function you should close at end of script