So a while ago I saw a proof of the Completeness Theorem, and the hard part of it (all logically valid formulae have a proof) went thusly:
Take a theory $K$ as your base theory. Suppose $\varphi$ is logically valid but not a theorem. Then you can add $\neg\varphi$ to $K$'s axioms, forming a new theory $K'$ which is consistent, and therefore $K'$ has a model $M$. Since $\neg\varphi$ is an axiom of $K'$, $M\models\neg\varphi$, but since $\varphi$ is logically valid in $K$ and $M$ is also a model of $K$, $M\models\varphi$, contradiction. Therefore, $\varphi$ must be a theorem of $K$.
Which makes sense to me, but I don't see how the above fails in second-order logic? This theorem looks perfectly generalisable to second-order logic, I don't see any steps that couldn't be done there.
Is the theorem correct? If not, why? If so, which part fails in second-order logic?
--EDIT:
As was commented, I got three isomorphic answers, and I can't set all of them as the true answer so I set the one that was phrased in the clearest way to me. In any case, thank you all!
The property that "every consistent theory has a model" does not hold for second-order logic.
Consider, for example the second-order Peano axioms, which are well known to have only $\mathbb N$ as their model (in standard semantics). Extend the language of the theory with a new constant $c$, and add new axioms $$ c\ne 0 \\ c\ne S0 \\ c\ne SS0 \\ \cdots $$
The extended theory is still consistent -- that is, it cannot prove a contradiction -- because a proof must be finite and can only mention finitely many of the new axioms, and there is a model as long as we only take finitely many of these axioms.
But the extended theory does not have a model, because the model will have to be exactly $\mathbb N$ in order to satisfy the original Peano axioms, but must have a $c$ that is not a numeral in order to satisfy all the new axioms.