There is another thread about this, but it did not fix my problem.
I wanted to share what I did to get the head lights working.
First off I will explain the problem I was having, the headlights would come on, but then after a bit they would go off and the dash lights and the parking lights would flicker off and on rapidly.
I checked the ground wires under the hood on the relay's. I also changed the relays, but still had the same problem. I even added ground wires to the correct pin on the under hood relay.
After great research, I found out there is a connector under the dash on the driver's side kick panel that has a bunch of ground wires that all connect together. This connector is covered with a blue cap, this may help you to locate it easier.
Here is the picture of the location, I had the dash out at the time (repainting it) so I took a picture from where the dash would have been. Its not required to remove the dash for this repair.
Here is the burnt connector:
Here is the blue cap that goes over this connector:
Assessment of problem:
Remove the blue cap from the the white connector, locate the wire/wires that are burned or damaged. You will most likely have to remove the wire from the connector to repair it. I will explain this in a bit.
Cause of problem:
What seems to cause the wires to burn is one or possibly two things. The connector cap will get corroded and sometimes cause a bad ground, its possible for several to become corroded.
This causes some of the wires not to be grounded at all, (a reason for no headlights) and this will sometimes cause too much current to be drawn through one or maybe more wires in that connector, they are too small to handle the extra load put on them. when this occurs, you have melted wires and or connectors.
Solution part one:
I used a tiny flat tip (regular) screw driver for electronics to remove the wire/wires and the pin/pins from the connector. You will have to use the screw driver to go into the connector (stick it in the same end that the wire enters it).
There is a little tab inside the connector where the burnt wire/wires are that will be sticking out to the side. Use the tiny screw driver to gently push the tab over so the wire can be slid out of the connector. It will slide out from the same side the wire enters the connector.
Once the damaged wire/wires are out, use something to clean the corrosion off of it. Baking soda and water will usually eat off mild to moderate corrosion. Just mix some up in a small cup and take it out to the car and dip the connector into the mixture.
Let it set for a few minutes, checking every couple of minutes to see how quickly its working. Take an old toothbrush and clean it some each time you check it. This will get the loose stuff off and let the soda start to work on the stubborn corrosion.
Once you have it clean as you can (you might use a tiny brass bristle brush to clean down in the female pins) Also do this same procedure on the blue cap, it has male pins.
Now you want to use some isopropyl alcohol to rinse the mixture off, again using the brush to get everything out. The alcohol dries quickly allowing you to put some dielectric grease on the pins: I will tell you more about that in a minute.
Doing the repair:
You will need to cut off any melted wire/wires and replace them with the same gauge of wire. NEVER USE A SMALLER WIRE THAN THE ORIGINAL!
The smaller wire will burn up because it cant handle the current, this could very well start an electrical fire.
Soldering the replacement wires on is much better than using a crimp on connector. If you don't have a soldering iron/gun crimp connectors is much better than twisting them together and using electrical tape.
Once you have the wires repaired stick them back into the white connector. Now put the dielectric grease into the pins on the white connector. Use your finger to push the grease down into the female pins. Also put some dielectric grease on the male pins (in the blue cap) this will keep the corrosion to a minimum on all parts.
Since my white connector was damaged, I chose to cut all the white wires from the white connector. I Stripped about 3/4" of the wire insulation from each of the white wires that were in the plug. Twist all these wires together making sure they are twisted tight, but not so tight you will damage them (don't use vice grips or pliers unless you absolutely have to) if you get carried away with it you can damage the wires by twisting them too tight.
I used a miniature propane torch to solder all the wires together. I prefer acid core solder, if you don't know how to solder its not hard at all. I am sure there are some youtube videos showing how to do it.
Once all those wires are soldered, I went a step further to ensure a good ground. I got a piece of 12 gauge wire and soldered a ring terminal on to one end of it, I stripped about 1" of the insulation from the other end and twisted it around all the white wires that were soldered together. Then I soldered the 12 gauge wire to those.
Putting it back together:
Connect the ring terminal to a place on the kick panel (making sure there is bare metal where the ring terminal is connected to the kick panel
Now use some good quality electrical tape and wrap the tape very tightly around the repaired areas. Heat shrink tubing is the best choice here but tape will work. Just make sure its tight to keep out the moisture.
Depending on the method of repair you chose, you will either put the blue cap back on the white plug, or cover the bare wires with heat shrink or electrical tape and attach the ring terminal to the kick panel.
Now to test the lights:
If the lights don't come on after doing this repair, this most likely means the DLRi s bad. (I think DLR stands for driving light relay)
Picture below: its the black box with the green-ish looking sticker on it.
Solution part two:
The DLR is located under the dash on the passenger side, You will have to remove the glove compartment to access this, remember you do not have to remove the dash to get to this. We were changing the interior color at the time that picture was taken.
Once the glove compartment is out, just look upward to the bottom side of the dash, you should locate it fairly easy.
It is attached by one of those plastic push pins that are attached to the wires going to the plug. These plastic things are just taped to the wire harness, and can be a PIA to get loose from the metal brace with out pulling it off of the wire harness.
You dont have to take it loose from the brace, but it was easier for me to get it unplugged if I removed it from the brace.
Now just plug in the replacement DLR, hopefully you will have a good used relay and the headlights will work.
If they still don't work, chances are you have a bad used DLR. These things are expensive from my local Toyota stealer-ship, (about $230). I went to my local salvage yard and found three of them, I got three because you never know if they will be good since thy are used and most likely came out of a wrecked car.
They wanted $20 each for them, but I asked them if they would take $45 for all three since I didn't know if they worked or not. Some salvage yards will not give a refund of any electrical item.
I do not know how to test the DLR, If someone has a Service manual for the 98-02 corolla I am sure it will tell how to test it.
If this doesnt fix the problem, I dont know what it could be. You will have to do more research online to find out why the lights still dont work.
I hope this helps someone out.