It is shown that accurate upper and lower bounds to the eigenvalues of anharmonic oscillators can be obtained by means of the Rayleigh-Ritz variational method and two trigonometric basis sets of functions which satisfy Dirichlet and Von Neumann boundary conditions. Numerical results show that the Dirichlet basis set is more appropriate than the harmonic oscillator one for calculating eigenvalues and the value of eigenfunctions at the origin.