Why don't we substitute for $p$ in $E = pc$? See, the energy of a photon is given out by $E = pc = hv$ why don't we substitute for $p$ in $E ^2= p^2 c^2 + m^2 c^4$ by putting $p = \gamma mv$ and then get a value for $m$ (which will be $0$ for a photon) and therefore rendering the equation to $E = 0$. I am just getting a bit confused.
EDIT
Since, $p= \frac{E}{c}$ can we conclude that the momentum for red light will be lesser than that for blue light as red light has less $E$ ?
 A: That's because the relation $p=\gamma mv$ doesn't hold universally. As you just showed yourself, using this relation for a photon would lead to a contradiction because the energy of a photon isn't zero.
A heuristic way of seeing why this relation won't hold for a photon is by recognizing that $$p=\gamma mv =m\frac{d x}{d\tau}$$
but a photon doesn't experience any proper time, so it wouldn't seem like a sensible idea to proceed in this fashion.
A: You can understand the expression by attempting the limit for $v\rightarrow c$ and $m\rightarrow0$. Notice that $\gamma\rightarrow\infty$ when $v\rightarrow c$. Therefore $m v \gamma$ is an undetermination of the form $0\cdot\infty$. From your expressions, you cannot say that $E=0$. The limit does not exist, and this implies that this expression is not valid for a massless particle.
Actually, if I can go a bit further, you can wonder what would happen if we relax one of the two properties: being massless and travelling at $c$. If the particle is not massless, then $E=m c^2 \gamma$ enforces the fact that it cannot travel at $v=c$, or otherwise $\gamma\rightarrow\infty$ and the particle would have infinite energy. Also, if it does not travel at $v=c$, then it cannot be massless, or otherwise it would not have energy. The conclusion of this would be that only massless particles can travel at $v=c$, and particles that travel at $v=c$ must be necessarily massless. In other words, a particle is massless if and only if it travels at $v=c$, which is actually a fact.
A: 
by putting $p=\gamma mv$ and then get a value for $m$ (which will be 0 for a
  photon) and therefore rendering the equation to $E=0$

First, let's write this out in full (in 1D)
$$p = \frac{m v}{\sqrt{1 - \frac{v^2}{c^2}}} $$
Then, solve for $m$
$$m = p\frac{\sqrt{1 - \frac{v^2}{c^2}}}{v}$$
Now, holding $p$ constant, see that the limit of $m$ as $v \rightarrow c$ is zero
$$\lim_{v \rightarrow c}m = 0$$
So, a massless particle can have non-zero momentum and thus, non-zero $E$ when $v = c$.
