drawing pixelmaps(RGB arrays) to screen/textures

I have been trying to draw pixel maps to textures

I have defined a RGB class made up of the attributes of unsigned char r,g,b

I have then created a 2d array of RGB’s called pixel and then used this command to draw it:
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,nCols,nRows,0,GL_RGB.GL_UNSIGNED_BYTE,pixel);

if I use a certain size of pixelmap (64) it draws it to the model but it gets completely corrupted and looks like a scottish tartan check, for a selection of pixelmaps.

Am I doing something wrong? Hows does openGL know how to maniplulate the “pixel” or the RGB if there user defined?

Please could someone help?

If 64*64 is working for you, you got the basic steps right.
Other texture sizes have to be power of two in that function.
Have a look at the settings you can do with glPixelStore.