When the sale of any land sold for the payment of taxes is, for any cause, ineffectual to pass the title to the purchaser, whether individual or the state, except in the case in which such sales are in this article expressly declared to be invalid, such sale shall operate as an assignment to the purchaser of the rights and liens of the state and county in and to the lands sold, both as to the taxes paid at said sale and as to the taxes subsequently paid by the purchaser, and such liens may be foreclosed in the same manner as other liens as provided in this title.