P0171 is a lean condition, you have a vacuum leak somewhere. However, I have seen that code come from a bad battery connection. Start by reading this. P0171
The p0306 is a misfire, likely caused by what ever is giving the p0171 code. However. Inspect the spark plug wire, pull the plug, inspect the coil. Because it is also possible the p0306 code is causing the p0171 code. In that case, it could be the injector.