Prove that there exists an integer $ x$ such that $ \frac{x^2-2}{p}$ is the square of an integer 
Let $ p\equiv -1\pmod 8$ be a prime number. Prove that there
  exists an integer $ x$ such that $ \frac{x^2-2}{p}$ is the square of
  an integer

This problem is from :
AOPS,there are some In the discussion, there was one person who did something worth doing, but it wasn't right.
Here's his   answer.
Let $(a,b)$ be a nontrivial solution to $x^2-py^2=1$. Then for $(c,d)=(2a,2b)$, $c^2-pd^2=4 \Longrightarrow c^2+d^2 \equiv 4 \pmod{8}$ $\Longrightarrow 4|c,d \Longrightarrow gcd(c-2,c+2)=2$. But we have $(c-2)(c+2)=pd^2$, so either:
i) $c-2=2pu^2$, $c+2=2v^2$, or
ii) $c-2=2u^2$, $c+2=2pv^2$, for some positive integers $u$, $v$.
ii) implies $ u^2-pv^2=-2 \Longrightarrow u^2+v^2+2 \equiv 0 \pmod{8}$, which is impossible, so we must have i).
But i) implies $v^2-pu^2=2 \Longleftrightarrow \frac{v^2-2}{p} = u^2$, which is a solution to the desired equation
As the last person pointed out, there was an important error in the answer：

$c^2-pd^2=4 \Longrightarrow c^2+d^2 \equiv 4 \pmod{8}$ $\Longrightarrow 4|c$  or  $4|d$. So maybe $gcd(c-2,c+2)=4$.

so this case How to prove it 

Let $p \equiv 7 \pmod 8$ be prime. Let $u,v > 0$ give the smallest positive solution to $u^2 - p v^2 = 1.$ Indeed $u \geq 3.$ Then $u^2 - 1 = p v^2,$ so $(u+1)(u-1) = p v^2.$ As $\gcd(u+1, u-1)$ is either $1$ or $2,$ we have four possibilities with some $\gcd(g,h) = 1:$
(I)
$$ u+1 = p g^2 \; , \; \; u-1 = h^2 $$
Subtracting gives $2 = p g^2 - h^2,$ or $h^2 - p g^2 = -2,$ which is impossible as $-2$ is not a quadratic residue $\pmod p.$
(II)
$$ u+1 =  g^2 \; , \; \; u-1 = ph^2 $$
Subtracting gives $2 =  g^2 - ph^2.$ 
(III)
$$ u+1 = 2 p g^2 \; , \; \; u-1 = 2h^2 $$
Subtracting gives $2 = 2p g^2 - 2h^2,$ or $h^2 - p g^2 = -1,$ which is impossible as $-1$ is not a quadratic residue $\pmod p.$
(IV)
$$ u+1 = 2  g^2 \; , \; \; u-1 = 2ph^2 $$
Subtracting gives $2 = 2 g^2 - 2ph^2,$ or $g^2 - p h^2 = 1.$ 
The hypothesis was that $u^2 - p v^2 = 1$ was the solution with smallest positive entries, so we have a contradiction. Note $2 g^2 = u+1,$ so $g < u,$ as $u \geq 3.$
