Restoring an iPhone 3gs that has been jailbroken?

I have recently bought a Blackberry however my old phone (iPhone 3GS) had been jailbroken so it was stuck on ios 3.1.2 and now I need to upgrade the software.
I opened up itunes and tried to upgrade but it failed so I clicked restore and that failed as well. Now I have no access to my phone and the screen is a usb telling me to connect to itunes. I really need some advice. Is it possible to get my phone working again!

Wow ios 3.1.2
Okay listen carefully.
1) Download the latest version of Redsnow and download Tiny Umbrella ( both on computer )
2) Plug in your device to your computer and now open Tiny Umbrella. On the far left you will see some letters or something that indicates your device is connected. Click on that.
3) Click on Exit Recovery on the right.

Your iPhone is now unbricked.

1. Go to http://iosdl.com/ and download ios 6.1.2 for your iPhone 3gs.
2. Extract that file to the desktop.
3. Open Redsnow. Click Extras. Click Even More. Click Restore. Click on ISPW and then open up the file with the ios 6.1.2 firmware. Now click Remote.
4. Your iPhone will take some time to upgrade all the way to 6.1.2 so be patient.
5. Thats it. If you want to jailbreak, download evasion.

Hope i helped.