Wavelength of photon changes as it rises from a planet's surface(acc. to this equation)? The setup assumes a large mass(Earth?) an a photon launched from its surface initially. The wavelength of the photon on launch is known. Then the new energy of the photon is compared with energy it traveled a distance $d$.

Initially, $$E_1 = \frac{GMm}{R} + \frac{1}{2}mv^2$$
where m- mass of photon, M is mass of earth, R is radius.
Finally $$E_2 = \frac{GMx}{R+d} + \frac{1}{2}xv^2$$
where $x$ is new mass of the photon.
Putting $m = \frac{h}{Lc}$,  $L$ is wavelength
Leet the new wavelength be $W$.
we can equate the 2: 
$$\frac{GMh}{RLc} + \frac{1}{2}\left(\frac{h}{L}\right)^2  =  \frac{GMh}{(R+d)Wc} + \frac{1}{2}\left(\frac{h}{W}\right)^2$$
Solving and putting $\frac{1}{W} = y$, we'll get,
$$\frac{h^2}{2}y^2 + \frac{GMhy}{(R+d)c}  =  \frac{GMh}{RcL} + \frac{1}{2}\left(\frac{h}{L}\right)^2$$
So this follows a quadratic equation $ax^2 + bx + c =0$ 
So that would mean that $y$ would keep decreasing as $d$ increases. Then it would mean that
the mass of the photon increases as it rises.
Is this logic correct or am I making a really blockheaded mistake here?
 A: A photon has zero mass, so you can't write it's kinetic energy as $\frac{1}{2}mc^2$.
You are thinking along the right lines. As the photon moves away from the earth it loses energy. However the loss of energy causes the photon to be red shifted i.e. it moves to a lower frequency. The photon energy is given by:
$$E = h\nu$$
and using your notation:
$$E_1 - E_2 = h\nu_1 - h\nu_2$$
You can use this to calculate the new frequency of the photon.
This frequency change has been measured using the Mossbauer effect. See http://en.wikipedia.org/wiki/Pound%E2%80%93Rebka_experiment for the details.
A: More correct post-newtonian equation is
${E_2-\frac{GM}{R_2}\frac{E_2}{c^2}=E_1-\frac{GM}{R_1}\frac{E_1}{c^2}}$
where $R_2=R_1+d$ and $E=h\nu\;$, so
$ {E_2\Big(1-\frac{GM}{R_2c^2}\Big)=E_1\Big(1-\frac{GM}{R_1c^2}\Big)}$
Then
$\large {\frac{\Delta\nu}{\nu_1}=\frac{\Delta E}{E_1}=\frac{E_1-E_2}{E_1}=1-\frac{E_2}{E_1}=1- \frac{\Big(1-\frac{GM}{R_1c^2}\Big)}{\Big(1-\frac{GM}{R_2c^2}\Big)}}=…=\frac{GM(R_2-R_1)}{ R_1(R_2c^2-GM)}$
Finally for $R_2\;>>\;R_S=\frac{GM}{c^2}\;$ and $\;d\;<<\;R_i:$
$\large {\frac{\Delta\nu}{\nu_1}\approx \frac{GM(R_2-R_1)}{ R_1R_2c^2} \approx  \frac{\mathbb{g} d}{c^2} }$
where $\mathbf{g}= \frac{GM}{R_1^2}$
