By design, the iPhone will sync iTunes content with one computer at a time. Any attempt to sync such content with a second computer will result in ALL iTunes content being first erased from your phone & then replaced with the content from the second computer. This is a design feature and cannot be overridden. Because you replaced your computer, or hard drive, your phone will see this as a "new" computer. The iTunes content sync is one way: computer to phone. If you have photos that were synced to your phone or music ripped on your own that were not backed up, you will first have to extract them from your phone using third party software, before you do anything else, as Apple makes no provision to do so:
If on a Mac, use this:
If on a PC, use this:
Once you've done that, do the following in the order specified:
1. Disable auto sync when an iPod/iPhone is connected under iTunes>Preferences>Devices(under Edit menu if using Windows).
2. Make sure you have one contact & one event in the supported applications on your computer(iCal & Address Book on a Mac, Windows Address Book or Outlook if using Windows). These entries can be fake, doesn't matter, the important point is that these programs not be empty.
3. Connect your phone, iTunes running, do not sync at this point.
4. Store>Authorize this computer.
5. File>Transfer Purchases(To make sure all purchased content on your phone will be in your iTunes library).
6. Right click your phone in the left device pane & select "Reset warnings".
7. Right click again and select "Backup".
8. Right click again & select "Restore from Backup", select the backup you just made. When prompted to create another backup, decline.
9. This MUST be followed by a sync to restore your iTunes content, which you select from the various tabs, You'll get a popup regarding your contacts & calendars asking to merge or replace, select "Merge".
Your phone should look just like it did when you started, with no data loss.
You should be good to go.