Latex problem with alignment character and &

1. Oct 27, 2014

HMPARTICLE

\begin{align*}
AB &= \sqrt{(2-(-1))^2+(3-4)^2}\\
&= \sqrt{3^2+(-1)^2}\\
&= \sqrt{10}.
\end{align*}

is what i am entering.
This is the error i am getting;

misplaced alignment character &.

I am baffled.

2. Oct 27, 2014

HMPARTICLE

for some reason it is working on here, but not in my latex editor, i have tried 2 different latex editors :(

3. Oct 27, 2014

Staff: Mentor

I guess it is a problem with the LaTeX editors, not a problem with the forum then.

4. Oct 28, 2014

Staff: Mentor

The error might be due to the code appearing before this.