Try to force your phone into recovery mode. Disconnect it from the USB cord. Turn it off if you can by holding the sleep/wake switch until you see the red slide to off. Press and hold the home button while plugging it into the computer's USB cord. Continue holding the Home button while iPhone starts up. While starting up, you will see the Apple logo. When you see "Connect to iTunes" on the screen, you can release the Home button and iTunes will display the recovery mode message.
http://support.apple.com/kb/HT1808
I had the same problem with my 3GS also.. I tried to force recovery "Push and hold both the sleep/wake button and home button at the same time. Keep holding and see if the apple logo appears. If it does, release both buttons at that time" but it's still turning back to the iPhone logo with a bar loading..