You should avoid using symbols such as $\frac{m}{x^2}$ when working in the integers, as a general rule. There are no fractions in the integers.
How do you know, for instance, that $x^2\mid m$? What if $x\mid m$ but $x^2\nmid m$.
Try to generalize as follows:
If $a,b\in \mathbb{Z}$, and $p|ab$, then $p|a$ or $p|b$. This is called Euclid's Lemma and, if you prove it, it should help you prove the assertion.
Edit: Since you've proven it, I'll add some more to give you variety.
Proof 1. By assumption, $p|x^3$. By Euclid's lemma we have $p|x$ or $p|x^2$. If $p|x$, then we are done. Suppose then $p|x^2$. Again, by Euclid's lemma we have $p|x$ or $p|x$. But that is what we are trying to show. $\square$
Proof 2. Assume $p|x^3$. Since every number can be uniquely factored into a product of primes, we can write $x=p_1^{a_1}\cdots p_s^{a_s}$. Consider $x^3=(p_1^{a_1}\cdots p_s^{a_s})^3=p_1^{3a_1}\cdots p_s^{3a_s}$. Since $p|x^3$, it must be in the set $\{p_i| 1\leq i \leq s\}$. But then, $p=p_i$ for some $i$, and is thus in the prime factorization of $x$, i.e. $p|x$.$\square$
The reason why the above proof is not a good place to start learning number theory is because it is essentially claiming $p\nmid x \implies p\nmid x^2 \implies p\nmid x^3$ and does not develop tools such as the $\gcd$ or Euclid's lemma.