  The unintegrated gluon density in the photon is determined, using the
Kimber-Martin-Ryskin prescription . In addition, a model of the unintegrated
gluon is proposed, based on the saturation model extended to the large-x
region. These gluon densities are applied to obtain cross sections for charm
and bottom production in gamma-p and gamma-gamma collisions using the k_t
factorization approach. We investigate both direct and resolved photon
contributions and make comparison with the results from the collinear approach
and the experimental data. An enhancement of the cross section due to inclusion
of non-zero transverse momenta of the gluons is found. The charm production
cross section is consistent with the data. The data exceed our conservative
estimate for bottom production in gamma-p collisions, but theoretical
uncertainties are too large to claim a significant inconsistency. A substantial
discrepancy between theory and the experiment is found for gamma gamma -> b
bbar X, not being cured by the k_t factorization approach.
