The thing is you got a fraction here:

where if you put x = -2 in, both the topandthe bottom are zero.

So what you do is you factorise the bottom, and you'll see that it has a factor of x+2. So divide top and bottom by x+2 and see what you're left with.