Why isn't my simple electromagnetic coil working? For a science fair project I am building a coilgun and so far it has been pretty easy but now I have run into an issue. I have 2 layers of coil wrapped around a straw and when I attach power to the coil and try and put something magnetic inside it it doesn't attract it at all. If you need pictures I would be glad to attach some.
EDIT Here are some images


 A: If it doesn't get warm there's no current flowing.  You didn't show the rest of your setup, but are the ends of the wire stripped?  Is there any possibility of a break in the wire somewhere?
If it does get warm the only other possibility is that you somehow reversed the wire when you started the second layer, and they're cancelling out magnetically.
A: You are sure that the object that you put inside the coil to test for attraction is really magnetic (i.e., it sticks to a refrigerator) and is not simply a non-magnetic metal? 
It would be helpful if you gave some information on the dimensions of your coil and also the gauge (diameter) of your wire as well as the amount of current you are running through the wire. 
Even without knowing this information, however, I think that the length of the coil is not optimal to generate a large magnetic field at the ends of the coil where you put your magnetic test object at in order to test for magnetic attraction. Look at it this way: The windings of the coil at the right end of the coil contribute a significant magnetic field to regions near the right end of the coil, but those windings at the far left end of the coil are rather far away and don't contribute much at all to the magnetic field near the right end of the coil. So a lot of the windings of the coil really aren't contributing much in exerting any significant magnetic force on a test object placed near the right end of the coil. 
I would change the aspect ratio of the coil so that the length-to-diameter ratio of it is not so large, and also increase the number of wire layers to something quite a bit more than just two. Do a Google image search for doorbell solenoids and you'll see that they have significantly smaller length-to-diameter aspect ratios and also many more wire layers than the electromagnet you made. 
A: Given that you said the battery gets hotter than the wire and that sparks happen when you disconnect it, you definitely have a good amount of current flowing. The sparks are caused by the inductance of the coil, so you know you have some magnetism being generated.
Your problem is that you simpky have nowhere near enough turns. You will likely need many many more than that to make an appreciable magnetic field. You may need at least 10x more layers than that to make a coil gun.
Another problem is that field strength is inversely proportional to the core length. If you wrapped the same amount of wire over a shorter section of straw, it would make a stronger magnetic field. Lengthening the magnet will not make it stronger, because the proportional increase in turns is exactly offset by the proportional increase in length, leaving the field exactly as strong as before.
In summary, your electromagnet is weak because there isn't nearly enough electro.
