This is a helpful document I got from one of my DE's teachers in graduate school, and I've toted it around with me. I will type it up here, as well as attach a pdf you can download.

THEOREM: Consider the Stürm-Liouville problem:
$$p(x) \, y''+p'(x) \, y'+q(x) \, y=k \, y$$
on the interval $[a,b]$ with $p(x)$ and $q(x)$ continuous, and $p(x)>0$. Assume either classical separated boundary conditions, namely, one of:
$$y(x)=0,\qquad y'(x)=0, \qquad y'(x)=c\, y(x)$$
at each endpoint $x=a$ and $x=b$; or else periodic boundary conditions:
$$y(a)=y(b), \qquad y'(a)=y'(b).$$
Then:
1. the only solutions are for $k$ real.
2. the set of all linearly independent solutions is complete for the usual
space of functions.
3. the set of linearly independent solutions is orthogonal.

COROLLARY: If the condition $p(x)>0$ fails because, at one endpoint, $p(x)=0$, then the classical separated boundary condition at that endpoint is replaced by:
$$y(x)<\infty$$
at that endpoint.

COROLLARY: If the Stürm-Liouville problem is modified by:
$$p(x) \, y''+p'(x) \, y'+q(x) \, y=k \, r(x) \, y$$
with $r(x)$ positive and continuous, and all other conditions the same, then the conclusions of the Theorem are still true, except that the orthogonality conclusion 3. is replaced by a "weighted orthogonality" with weighting function $r(x)$:
$$\int_a^b y_n(x) \, y_m(x) \, r(x) \, dx=0 \quad \text{whenever} \quad n\not=m.$$

Example 1: $y''=ky$ on $[0,\ell]$ with $y(0)=0, \; y(\ell)=0$. Then there are solutions only for $k=-\lambda_n^2=-\dfrac{n^2 \pi^2}{\ell^2}, \; n=1,2,3,\dots$ and $y_n=c_n \, \sin\left(\dfrac{n \pi x}{\ell} \right)$. This gives the Sine series.

Example 2: $y''=ky$ on $[0,\ell]$ with $y'(0)=0, \; y'(\ell)=0$. Then there are solutions for $k=-\lambda_n^2=-\dfrac{n^2 \pi^2}{\ell^2}, \; n=1,2,3,\dots$ and for $k=0$. In the second case, $y=1$ and for $n=1,2,3,\dots, \; y_n=c_n \, \cos\left(\dfrac{n \pi x}{\ell} \right)$. This gives the Cosine series.

Example 3: $y''=ky$ on $[a,b]$ with $y(a)=y(b), \; y'(a)=y'(b)$. Then there are solutions for $k=-\lambda_n^2=-\dfrac{4 n^2 \pi^2}{(b-a)^2}, \; n=1,2,3,\dots$ as well as $k=0$. Further, for each $n\ge 1$ there are two linearly independent solutions, $y_n=a_n \, \sin\left(\dfrac{2n\pi x}{b-a}\right)$ and $y_n=b_n \, \cos\left(\dfrac{2n \pi x}{b-a}\right)$. For $k=0, \; y_0=a_0$. This gives the Fourier series.

Example 4: $xy''+y'=kxy$ with $y(0)<\infty$ and $y(\ell)=0$. There are solutions for certain $k_n=-\lambda_n^2<0, \; n=1,2,3,\dots$ Call the solutions $g_n(x)$. Then the functions $g_n(x)$ are complete on the interval $[0,\ell]$ and are
orthogonal with respect to the weight $x$:
$$\int_0^{\ell}g_m(x) \, g_n(x) \, x \, dx=0 \quad \text{whenever} \quad n\not=m.$$
It turns out that $g_n(x)=J_0(\lambda_n x)$ for the zeroth Bessel function $J_0(x)$.

Attached file: