The result is FALSE in general, even in one dimension.
Consider $f:(0,1) \cup (1,2) \to \mathbb{R}$ by $$f(x) = \left\{\begin{array}{lr} 0 & x \in (0,1)\\1 & x \in (1,2)\end{array} \right. $$ We have that $f'(x) = 0$ for all $x \in (0,1) \cup (2,3)$, but $f$ is not constant.
We do, however, have the following theorem which states that $f$ must be constant on the connected components of its domain:
Theorem. Let $U \subseteq \mathbb{R}^N$ be an open set, and suppose that $f:U \to \mathbb{R}$. If for every $x \in U$ and all $i \in \{ 1, \ldots, N\}$ there is $\frac{\partial f}{\partial x_i}(x) = 0$, then $f$ is constant on each connected component of $U$.
There are many proofs, and I will outline one here:
Proof.
Step 1: Prove that for every $x \in U$ there is a neighborhood of $x$ on which $f$ is constant. This result follows immediately from the Mean Value Theorem and the fact that $U$ is open.
Step 2: Let $K$ be a connected component of $U$. We know that $K$ is open since the connected components of an open set in $\mathbb{R}^N$ are open. Choose $x_0 \in K$, and define $V := f^{-1}(f(x_0))\cap K$. By step 1 we have that $V$ is open. Since $f$ is constant in a neighborhood of every point, it follows that $f$ is continuous. Hence $W:=f^{-1}(\mathbb{R}\setminus\{f(x_0)\}) \cap K$ is open (since $K$ is open). We note that $V \cup W = K$, and $V \cap W = \emptyset$. Since $x_0 \in V$ it follows that $V \neq \emptyset$. Hence we must have that $W = \emptyset$, otherwise $(V,W)$ would be a separation of $K$ which would be a contradiction since $K$ is connected. It follows that $K=V$ so that $f(x)=f(x_0)$ for all $x \in K$. $\blacksquare$