Arduino Mega 2560 + esp8266-01+MQTT

I am compararitively new to arduino. I have managed to get the ESP 8266 using AT Commands. However I am Interested in using the system as a MQTT client. I would like to know the following

  1. ARDUINO MEGA has 4 commports which RX,TX do I connect to ESP TX,RX respectively. How do I select the combination.

  2. I using and external Supply and I am getting the following problem during uploading to ESP8266 shield

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

board selected is ESP8266 Generic.

Do I need to change the board selection.

Thanking you in advance.

  1. ARDUINO MEGA has 4 commports which RX,TX do I connect to ESP TX,RX respectively.

Whichever pair you want.

How do I select the combination.

   int combo = random(1, 5);
  1. I using and external Supply

An external supply of what? Lima beans?

and I am getting the following problem during uploading to ESP8266 shield

Doing something that we can't see, trying to upload something that we can't see, over some wires that we can't see, you have a problem. And, you want us to solve it? My crystal ball got dropped. It's due back the 12th of never. If you need help before then, I hope you can think of something.