How to Stop an IPhone From Erasing Music Each Time You Connect It to a Different Computer
Apple's iPhone can sync music with iTunes only on a single computer. If you try to sync your phone on a second computer, iTunes will warn you that proceeding will erase all the music already on the phone. This doesn't mean that you can't connect your phone to multiple computers, however: you can safely charge your phone, sync different types of media on different computers or manage your music manually on as many computers as you like.
1 Actions That Support Multiple Computers
Without changing any settings on iTunes or your iPhone, you can use your iPhone on multiple computers in several ways without risking your music library. On any computer with iTunes, you can plug the phone in to charge it. If you open iTunes, the program will ask if you want to access the phone's data. Giving a new computer access won't erase anything, and will let you see the phone's current library. By opening the library, you can play the phone's music through your computer's speakers without needing to transfer it. To play content purchased in iTunes, you may need to authorize the computer with your Apple ID.
2 Syncing Other Data
ITunes syncs iPhone data in several sets, each of which can work with only one computer. You can't sync a second computer's music, movies, TV shows, books or ringtones without erasing existing music, but if you uncheck these sync options, you can transfer other types of data without losing your music. For example, you can sync podcasts, photos or apps from a different computer, or even use one computer for music, one for apps and a third for photos.
3 Managing Music Manually
If you need to copy music from multiple computers regularly, you can do so manually instead of using iTunes' sync feature. Connect your phone to your primary computer, open the phone's Summary tab in iTunes, check the "Manually manage music and videos" box and click "Apply." To copy songs manually from any computer, press "Control-S" in iTunes to turn on the sidebar and drag music from the iTunes library into the iPhone section of the sidebar. You can also drag in music files on your computer without adding them to the iTunes library first.
4 Replacing Your Computer
If you want to permanently sync with a new computer, you need to copy your old iTunes library to the new machine. If you copy only your music files and create a new library, iTunes will lose metadata such as play counts. To preserve this information, install iTunes on the new computer, quit the program and then move the entire iTunes library folder to the new computer. The first time you sync, your phone will still warn you about syncing with a new computer, but it will not actually lose any data.