I have the mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in....& Undefined variable: link in..... error.i use the $link in my code.but i dont where is my code is wrong. this is my code:
    function Check_Get($value)
{
    include 'connect.php';
    $return1 = mysqli_real_escape_string($link,$value);
    $return2 = htmlspecialchars($return1);
    $return3 = intval($return2);
    return $return3;
}
-------------------------------
if(isset($_POST['login'])){
    if($_POST['username']=="" || $_POST['password']=="" || $_POST['email']=="")
    {
        $security->Redirect("index","empty=1020");
    }
    else{
    }
}
-------------------------------
    if(isset($_GET['empty']))
    {
        $security->Check_Get($_GET['empty']);
        $template->message("please fill all field","red");
    }
-------------------------------
this is my connection code:
$Server_name = "localhost";
$Server_username = "root";
$Server_password = "";
$db_name = "news";
$link = mysqli_connect($Server_name,$Server_username,$Server_password) or 
        exit ("Error in Connection to Server");
if($link)
{
    if(mysqli_select_db($link,$db_name))
    {
        mysqli_query($link,"set names utf8");
        mysqli_query($link,"set charset utf8");
        $result = mysqli_query($link,$sql);
        if(!$result)
        {
            echo "Error in Query";  
        }
        return $result;
    }
    else
    {
        echo "Error in Connection to DataBase";
    }
}
else
{
    echo "Error in Connection to Server";
}
;
 
    