A code P0171 refers means that your car is experiencing a lean fuel situation. Possibly fuel injectors, fuel filter, fuel pump or a number of other systems that effect the fuel/air ratio, such as the EGR.
I suggest, first try some fuel injector cleaner and changing the fuel filter (since those are the easiest and cheapest) and go from there.
If you are getting a misfire code for a specific cylinder, then the fuel injector for that cylinder is likely bad.