for the past 3 months I have removed several transformers from PCBs to try and use it for a different purpose ,but as I connect it to a 230v main supply they just keep exploding . I don't think my problem is that I'm using the wrong terminals , frequency or voltage because the transformer came from a circuit using exactly 230 volts .Can someone please explain to me what am I doing wrong .
Assuming you are talking about the ones from switch mode power supplies (tiny things), they don't run at 50Hz, the run at several tens of kHz.
In SMPS's, the mains is rectified to DC then switched through the transformer at a much higher frequency. This allows for physically smaller transformers.
If you connect one straight to the mains, you'll be running it at much lower frequency than it is rated for at that voltage, and hence orders of magnitude higher current than it's rated for (remember, inductor impedance is directly proportional to frequency). The net result is bang.
The moral really is don't try to wire up any component without reading it's datasheet. If you don't have a datasheet, don't use it.