convert mysql to mysqli error : I'm trying to convert mysql to mysqli, but I get some errors

first error :
mysqli_query() expects at least 2 parameters, 1 given in /home/.........../class/class.mysql.php on line 55

    public function query($res, $pass_no = 1) {
        $q1 = mysqli_query($res, $this->db_link);
        if (!$q1) {
            $this->sql_error();
            if ($pass_no == 1) {
                if ($this->output_error == 1) {
                    echo 'Attempting to reconnect to MySQL...' . "\n";
                }
                $this->db_close();
                $this->db_connect();
                $this->query($res, 2);
            } else {
                if ($this->output_error == 1) {
                    echo 'Reconnection failed; please check your MySQL server settings!' . "\n";
                }
            }
        } else {
            return $q1;
        }
    }
second error :
mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /home/..../index.php on line 14

    global  $db ;
  
   	$username = mysqli_real_escape_string($_POST['username_login']);

    	  $q ="select * from ".DB_PREFIX."admins where username='".$username."' ".
	        "and password='".md5( $_POST['password_login'])."'";
	   // echo $q;
	    $res =$db->query($q);
	    if($db->num_rows($res)==1)
	    {
	       
	        return true ;
	    }
    
    return false ;


I don't understand the 2 errors