Another very basic tip: if you're not using the display, turn it off. Rather than waiting for the display to deactivate by itself, or worse, leaving it on all the time, once you've finished browsing for the song or whatever else you're looking for, push the iPhone's hold switch to lock the screen.
Other tips for prolonging iPhone battery life generally involve turning off features in your device's Settings: Location Services, Push Notifications, Wi-Fi, Bluetooth, iPod equalizer, and 3G are all things you can deactivate in order to get more life out of your iPhone's battery. In a pinch, you can also put the iPhone into Airplane Mode, which essentially shuts most of those services off at once -- of course, that transforms your iPhone into a more expensive version of an iPod touch, so it's probably something you'll only want to do if you have no wireless reception anyway or your device's battery is nearly drained.
The iPod tips are mostly the same as for the iPhone, and Apple's iPod page even has a link to a monthly iCal subscription that will remind you to completely discharge and charge your device's battery once a month. This reminder probably isn't necessary for iPhones, since people tend to use those daily, but it comes in handy if you have an iPod that you're not using very often. This reminder is important if you're not using your device on a regular basis, because Apple recommends putting iPods through at least one full charge-discharge cycle per month in order to keep the battery healthy. The iPod page also has tips specific to hard-drive-based iPods, such as limiting fast-forwarding or skipping through songs and keeping song file sizes below 9 MB. Both tips ensure the iPod's hard drive doesn't have to spin up as often, thereby increasing battery life.
I usually keep all the services on my iPhone 3G turned on, and between gaming, browsing, and app use, I generally go through a complete charge cycle every other day. When I'm travelling and certain to be away from a power outlet for a long time, Location Services is generally the first thing I turn off -- the iPhone's GPS antenna seems to be responsible for a big portion of the device's battery drain.
Apple says the batteries on iPods and iPhones should retain 80% capacity after 400 full charge-discharge cycles, so to make sure you get the best use out of them both in the short and long term, make sure to follow the battery guidelines on Apple's tips pages for both iPhones and iPods.