Someone correct me if I'm wrong, but from what I remember:
λ=h/p
from mechanics: p=mv
so: λ=h/mv
Photons move at the speed of light, so v=c
λ=h/mc
At the same time, from Einstein: E=mc^2
m=E/c^2
thus: λ=h/[(E/c^2)c]
λ=h/(E/c)
λ=hc/E
So basically both equations are related, but not quite the same. You need to apply them depending on what variables are known and which ones you are trying to find.
I hope that helps.