Know your enemy. First thing we do when we encounter hostile humanoids is to ask what they're wearing - NPCs are just like PCs, they take equipment that plays to their strengths, so you can be pretty sure someone in fullplate is either a fighter or a cleric, someone without armor but a lot of wands is probably a wizard, etc. Most big "tough" monsters have good fortitude saves, but poor will saves.
Use the right spells against the right enemies. Fireball isn't going to do much to the rogue (who you figured out is just that because you asked what he was wearing and the DM said black leather and wielding a shortsword), but it'll tear up the fighter (full plate) and the wizard (robes, wands). Use spells with will and reflex saves against the fighters and big monsters, and the will saves and fort saves versus rogue types.
Know your spells... if you cast a spell that isn't dismissable (stinking cloud), make sure it's not going to screw you later in the fight.
I concentrate a lot on spells here because they're often the places where people have difficulty.. there's a lot to read and a lot to know.... but if you use them judiciously, you'll be a great help in any battle.
And sometimes you have to realize when you're just not going to be any help in a particular battle. Wizards in a battle against golems just aren't going to affect the creature much. If your character knows a kind of energy will slow the creature, then use that, but otherwise, just get out of the way.
When only one or two melee fighters is useful in a fight, due to high AC or damage reduction, if there are other melee guys standing around, don't just sit there like a bump on the log, give that guy all the help you can! One guy should flank, another should be using aid another... that's +4 to hit, that's a significant difference.
People often say don't clump, but it's just as true that you shouldn't spread yourselves too thin. Unless you greatly outmatch your enemies, it can hurt a lot if you run into the middle of the gang of enemies, and they all surround you and start pounding on you. Staying reasonably close together, like 5-10 feet between each person, assures that you can move to help each other without incurring too many attacks of opportunity, and that if anyone tries to surround you, they'll get surrounded in turn.
Always have ranged weapons!! I don't care if your fighter is greater weapon specialized in greatsword and has a +5 holy vorpal greatsword of flaming death, there's no excuse not to have a composite longbow hanging around. There are way too many flying baddies out there that just require arrows, not to mention when you get ambushed from across a chasm or something.
-The Souljourner