Connect your iPhone 3GS to iTunes and do the following:
1.On the summary tab of your iTunes sync settings check "Sync only checked songs and videos"
2.In your music library check all the songs you want to sync to your iPhone
3.Make sure there are no exclamation points next to any of the songs you want to sync to your iPhone
4.Make sure you have authorized your computer for all Apple IDs for purchased music you want to sync to your iPhone (in Store>Authorize This Computer)
5.Check "Sync Music" on the Music tab of your iTunes sync settings
6.Sync your iPhone