Products of Electrolysis of NaCl
The one solid answer is that everything you've heard is right, given the appropriate conditions.

If the cathode and anode spaces are properly separated with a porous membrane or a salt bridge, then it is just like that:
$$\ce{2NaCl + 2H2O -&gt; \underbrace{2NaOH + H2}_{cathode} + \underbrace{Cl2}_{anode}}$$
If they are not, then the products inevitably mix with each other and react further:
$$\ce{2NaOH + Cl2 -&gt; NaCl + NaClO + H2O}$$
or, at elevated temperatures,
$$\ce{6NaOH + 3Cl2 -&gt; 5NaCl + NaClO3 + 3H2O}$$
See, chemistry is diverse. Oh wait, and there are more options. Think of the mercury cell.