Every ideal in $\mathbb{Z}[\sqrt d]$ is finitely generated by at most two elements of the form $a, b + c \sqrt d$ I'm trying to show that every nonzero ideal in $\mathbb{Z}[\sqrt d]$ is finitely generated and I'm trying to achieve that by showing that
if $d$ is squarefree and $d \neq -1$ then is it true that for every nonzero non-principal ideal $I$ in $\mathbb{Z}[\sqrt d]$, there exists $a, b \in \mathbb{Z}$ such that $I = (a, b\sqrt d)$. I think this is true but this post Prove that every nonzero prime ideal is maximal in $\mathbb{Z}[\sqrt{d}]$ says that the generators actually are $a, b + c \sqrt(d)$ so i dont know why or which part of the statement of the beginning is wrong. And if it is wrong, how could I go about proving that the ideals are finitely generated.

Every non-zero ideal $I\lhd\mathbb{Z}[\sqrt{d}]$ must have non-zero intersection with $\mathbb{Z}$ (that is easy to see) so $I\cap\mathbb{Z}$ is a non-zero ideal of $\mathbb{Z}$ and therefore principal so choose a generator $a>0$. If $I=(a)\lhd\mathbb{Z}[\sqrt{d}]$ we are done, so assume that $(a)\subsetneq I$. Then there are elements of form $x+y\sqrt{d}\in I\setminus(a)$ and we can take integer combinations of these with multiples of $a$ to get $b+c\sqrt{d}\in I\setminus(a)$ where either $b=0$ or $b>0$ is minimal. A straightforward argument now shows that every element of $I$ is in $(a,b+c\sqrt{d})$.
A similar argument works to show the result for the ring of integers in $\mathbb{Q}[\sqrt{d}]$ when $d\equiv1\bmod{4}$, this is the set of numbers of form $a+b\dfrac{(-1+\sqrt{d})}{2}$ where $a,b\in\mathbb{Z}$. For other $d$, the ring of integers is $\mathbb{Z}[\sqrt{d}]$.
