How many personal fouls does a player get before being ejected from an NBA basketball game?

Before being dismissed from the game, you are allowed six personal fouls. If you commit a flagrant foul, which is an extremely aggressive foul that can be interpreted as intentionally injuring the player, you will not be expelled.