If $D$ is a PID and $a,b,m\in D$, then the equation: $$ ax\equiv b \pmod{m} $$ has solution $x \in D$ iff $b$ divides $(a,m)$.
I have proved the left to right implication but I'm trying so hard the other and I don't get it. I will appreciate any suggestion. Thank you!
Hint $\ $ In a PID, $\,\ (a,b) = (\gcd(a,b))\,$ and $ $ divides = contains: $\,a\mid b\iff (a)\supseteq (b).\,$ Hence
$\gcd(a,m)\mid b\iff (a,m)=(\gcd(a,m))\supseteq(b)\iff b = ax+my\iff b\equiv ax\pmod{m}$