To all, I'm learning so these may be stupid questions. Please put the flamethrowers down.

Are you still using the 16F877? If so:

Does ADCON1 = 7 do anything for you? It looks like none of ADC ports are on Port D and this wouldn't effect them.

I don't think of the TRISX as setting ports to digital only setting them input or output. With the 877 are the ports already set so with a high you get 5V out and a low gives you zero when you set them as outputs?

If you're continuing to have issues with ghosting I found, on the 12F683, that setting all ports to input and turning them off before I moved on to the next light helped quite a bit.

Hope it helps.