Here you go.
How to restore a 3g iphone and install os 4.02, follow closely.
step 1- do a hard reset to turn phone off, wait a minute till you do next step.
step 2- turn on your phone.
step 3- open itunes on your computer, do not plug phone in yet.
step 4- after phone is started up and itunes is started up, plug in phone.
step 5- after phone is seen by itunes, verify that you have downloaded os4.02
step 6- if you have not click check for update, download if needed.
step 7- double click the text next to the iphone icon to highlight it.
step 8- rename your iphone to say something like Drews iphone ??//??/???? date
step 9- by renaming your phone you can insure backup, sync and backup phone now
step 10- wait, be patient, dont rush, this takes a while, seems forever.
step 11- make sure your computer does not go to sleep.
step 12- after the sync and backup are complete, verify backup by holding the ctrl key down and right click on the device to pull up drop down menu.
step 13- click restore from backup to verify that your backup with new phone name is in the choices to backup from, do not perform a restore from backup right now.
step 14- now after you have verified that your backup is actually there, click restore, this will erase all data from your phone. this will take a few minutes, now would be a good time for a second cup of coffee.
step 15- after the restore is complete, you now have a iphone 3g with 0s4.02, and no other data on it. Make sure your phone remains plugged in this whole process, do not unplug phone, I cannot stress this enough, and dont rush it.
Now you can hold down the ctrl key and right click on the device in itunes and select restore from backup, select the backup with the new name and with the date you changes, this is the last backup you made, you can rename the iphne later. Let the computer do the restore from backup to lay down all of your contacts, emails, and apps. You will most likely need some usernames and passwords for wifi and such.
step 16- after the restore from backup is complete let the phone connect to the cellular network by itself, do not unplug. after the phone displays " connected to cellular network, you can quit itunes and uplug your phone.
Now your iphone 3g is loaded with a fresh copy of 0s 4.02 and all of your stuff is back the way is was with the previous os.
I did not have the same luck with an "upgrade"
The Iphone 3g must be restored as a new phone with os 4.02 and restored from a good backup to work.
Good luck.
Andrew