We present a search for the standard model Higgs boson and a fermiophobic Higgs boson in the diphoton final states based on 8.2 fb(-1) of pp collisions at sqrt[s]=1.96 TeV collected with the D0 detector at the Fermilab Tevatron Collider. No excess of data above background predictions is observed and upper limits at the 95% C.L. on the cross section multiplied by the branching fraction are set which are the most restrictive to date. A fermiophobic Higgs boson with a mass below 112.9 GeV is excluded at the 95% C.L.