# Prove that if p is an odd prime then $x^2=2 \pmod p$ has solutions if and only if $p\equiv \pm 1 \pmod 8$

I was going to break up $p$ into $8k+1$ and $8k+7$. Using this, I can plug that in for p and then solve using this.

Here is a proof that $\left( \frac{2}{p} \right) = (-1)^{(p^2-1)/8}$, which is basically what you are looking for:
This says that $2$ is a quadratic residue $\bmod{p}$ if and only if $(p^2-1)/8$ is even. (Saying that $2$ is a quadratic residue is the same as saying that there is a solution to $x^2 \equiv 2 \pmod{p}$.) It is not difficult to check that: $(p^2-1)/8 = (p-1)(p+1)/8$ is even iff one of the factors $p-1,p+1$ is divisible by $8$.