Domain — Search your library for a basic land card, put that card onto the battlefield tapped, then shuffle. Exploding Borders deals X damage to target player or planeswalker, where X is the number of basic land types among lands you control.
Domain abilities count the number of basic land types among lands you control, not how many lands you control or how many of any type.
The basic land types are Plains, Island, Swamp, Mountain, and Forest. Land types other than basic land types (such as Desert) don't contribute to domain abilities.
Exploding Borders has only one target: the player. If that player becomes an illegal target by the time Exploding Borders would resolve, the entire spell doesn't resolve. You won't get to search for a basic land card.
Exploding Borders will still deal damage even if you don't put a land card onto the battlefield.
You do what the spell says in order, so you'll put a new basic land card onto the battlefield before you determine the value of X.