Help with Modern OpenGL Call Function to create Texture ?

Hi, I’m trying to work with multi-texture using SOIL. I think it’s a mistake of how I call the texture. I have 2 textures now with 2 different image source (Texture 1 and Texture 2), they look like this :
Texture 1 :

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures[0]);
(...)
image1 = SOIL_load_image("res/img1.png", &width, &height, 0, SOIL_LOAD_RGBA);​  //for image 1, "res/img2.png" for image 2
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image1);
SOIL_free_image_data(image1);

image 1 for Texture 1 & image 2 for Texture 2.
It’s working, and I can call them by changing between texture. Now I’m trying to change the image source for texture 1 and texture 2 as the same image (img0). I will do some pixel modification for the img0, and store the results as texture 1 and texture 2.

I created function changed(), which contains the image modification code. Something like this :

void changed()
{      unsigned char *t, *t1, *t2;
	if (image1 == NULL) {
		image1 = (unsigned char *)malloc(width*height * 4);  
		if (image1 == NULL) exit(0);}
	if (image2 == NULL) {
		image2 = (unsigned char *)malloc(width*height * 4);
		if (image2 == NULL) exit(0); }

	t = image;
	t1 = image1;
	t2 = image2;

	for (int i = 0; i < height*width; i++) {
		if (*t == 0 && *(t + 1) == 0) { 
			*(t1 + 0) = 255; *(t1 + 1) = 255; *(t1 + 2) = 255; *(t1 + 3) = 0;
			*(t2 + 0) =   0; *(t2 + 1) =   0; *(t2 + 2) =   0; *(t2 + 3) = 0; 
                    }
(and several more for conditions) }

From that function, I want to save t1 as source for texture 1, and t2 as source for texture2, so I can call and switch between them later. I tried to call the the function like this :

//create texture========================================================================
GLuint textures[2];
glGenTextures(2, textures);

image = SOIL_load_image("res/img0.png", &width, &height, 0, SOIL_LOAD_RGBA);
if (image == NULL) exit(0);
image1 = NULL;
image2 = NULL;
changed();

//Texture 1
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures[0]);
(...) 
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image1);
SOIL_free_image_data(image1);

//then Texture 2 with image 2

But it doesn’t work, no error and no image drawn to the scene.
I checked with changing the clear color buffer value, and the color buffer works.
So it’s the problem with calling the function and passing my image. Any suggestion ?

since I can’t update the question. I have some progress

[UPDATE]

I added error handling code to check, like this :

	while (!(err = glGetError())) { 		
            cout << "some error message" << err << endl; 	
        }

And turn out the error is after my loading source image code :

image = SOIL_load_image("res/img0.png", &width, &height, 0, SOIL_LOAD_RGBA);

How do I properly load an image using SOIL as a source for a function ? This is the same way I did it with GLUT and it’s working, is it different with GLFW ?