Problem with glBindTexture

I’m having a really strange problem with glBindTexture: when I try to bind a texture to load the actual data onto it, glBindTexture(GL_TEXTURE_2D, textureID) gives error 0x0500 (INVALID_ENUM) just like GL_TEXTURE_2D isn’t a valid constant. The strangest thing is that if I call glBindTexture() two times (one after another) the second time the function doesn’t give any error but the texture isn’t displayed anyway. The texture data is loaded correctly because glDrawPixels draws it correctly. Very similar code by NeHe works fine. My system is: Win XP, Visual C++ 6.0 and a GeForceFX 5800.
Please Help!

Just for more info: i’m using MFC and when i call glBindTexture the rendering context is active. Thanks again for help.

do you call glGenTextures ?
if so, test gl error after genrate the texture name:
if ((error=glGetError()) != GL_NO_ERROR)
{
print the string returned by glu
}

I call glGenTextures(1, texID), where texID is a GLint pointer. It also gives INVALID_ENUM error which has no sense as in the OpenGL manual it is not a contemplated error for glGenTextures… i’m going crazy with this!

Check the rendering context. It must be valid at the point you start calling OpenGL functions.

Thanks to all. Problem resolved. Just have to set the texture filters for the textures I loaded.