Why is it not true that $\int_0^{\pi} \sin(x)\; dx = 0$?
Solution 1:
This is a very good question and not one that many students ask. Let's see what happens when we do as you are suggesting. Letting $u = \sin x$, we get
$$du = \cos x\,dx = \pm\sqrt{1-\sin^2 x}\,dx = \pm\sqrt{1-u^2}\,dx.$$
Thus the integral becomes
$$\int \sin x\,dx = \int \frac{\pm u}{\sqrt{1-u^2}}\,du.$$
Notice I did not put any limits of integration in here. When $x\in[0,\frac{\pi}{2}]$, cosine is non-negative, so we can use the positive root. However when $x\in(\frac{\pi}{2},\pi]$, cosine is negative so we have to use the negative root. Meaning our one integral splits into two different integrals:
$$\int_0^{\pi} \sin x\,dx = \int_{u(0)}^{u(\pi/2)} \frac{u}{\sqrt{1-u^2}}\,du + \int_{u(\pi/2)}^{u(\pi)} \frac{-u}{\sqrt{1-u^2}}\,du.$$
Note that $u(0) = 0$, $u(\pi/2) = 1$ and $u(\pi) = 0$ so we get
$$\int_0^{\pi} \sin x\,dx = \int_0^1 \frac{u}{\sqrt{1-u^2}}\,du - \int_1^0 \frac{u}{\sqrt{1-u^2}}\, du = 2\int_0^1 \frac{u}{\sqrt{1-u^2}}\,du.$$
Note that this is a positive number. The reason for why it doesn't work out is exactly as Baloown is suggesting. What you suggest does not apply here and is partially reflected in the occurrence of the $\pm$ roots. What the actual case is that the forward direction for $u$-substitution always works (meaning substituting $x = \text{ something}$) - it is the backwards case is where the issues lie (substituting $\text{something } = f(x)$).
Solution 2:
\begin{align} u & = \sin x \\ du & = \cos x\,dx \\[8pt] dx & = \frac{du}{\cos x} = \frac{du}{\pm\sqrt{1-\sin^2 x}} = \frac{du}{\pm\sqrt{1-u^2}} = \begin{cases} \dfrac{du}{\sqrt{1-u^2}} & \text{for }0\le x \le \frac \pi 2 \\[10pt] \dfrac{du}{-\sqrt{1-u^2}} & \text{for } \frac \pi 2 \le x \le \pi \end{cases} \\[15pt] \int_0^\pi \sin x\,dx & = \int_0^{\pi/2} \sin x\,dx + \int_{\pi/2}^\pi \sin x\,dx = \int_0^1 \frac{u\,du}{\sqrt{1-u^2}} + \int_1^0 \frac{u\,du}{-\sqrt{1-u^2}} = \cdots \end{align}
Solution 3:
As suggested in the other answers, you cannot use that substitution on the whole interval $(0,\pi)$ because $\sin $ is not bijective there. However, you can do the change of variables after having split the interval into two pieces on which $\sin $ is bijective: $$\int_0^\pi\sin x\,\mathrm{d}x=\int_0^{\pi/2}\sin x\,\mathrm{d}x+\int_{\pi/2}^\pi\sin x\,\mathrm{d}x=\int_0^1\frac{u}{\sqrt{1-u^2}}\mathrm{d}u+\int_1^0\frac{-u}{\sqrt{1-u^2}}\mathrm{d}u\,,$$ having used the fact that $\cos x=\sqrt{1-u^2}$ on $(0,\pi/2)$ while $\cos x=-\sqrt{1-u^2}$ on $(\pi/2,\pi)$.