Question regarding the definition of a projective module Referring to Lang's Algebra p.137 P1, an $A$-module $P$ is projective if the following property holds: given $A$-homomorphism 
$f:P \longrightarrow M^{''}$ and surjective $A$-homomorphism $g:M \longrightarrow M^{''}$, then
there exists  $A$-homomorphism $h:P \longrightarrow M$ such that $f = g \circ h$.
I am confused as follows: let $P$ be any $A$-module (not necessarily projective) and let $f$, $g$ be as above. Now let $\left\{u_i\right\}_{i \in I}$ be a set of generators of $P$. For every $u_i$ there exists some (not necessarily unique) $\xi_i \in M$ such that 
$f(u_i)=g(\xi_i)$, since $g$ is surjective. Then according to the straightforward Theorem 4.1 p.135 (again from Lang) there is a unique $A$-homomorphism $\psi:P \longrightarrow M$ such that $\psi(u_i)=\xi_i$. But then this $\psi$ is such that $f = g \circ \psi$ and so by definition $P$ is projective. What am i missing?
Thank you :-)
 A: Theorem III.4.1 on p. 135 of Lang's Algebra says:

Let $A$ be a ring and $M$ a module over $A$.  Let $I$ be a nonempty set, and let $\{x_i\}_{i \in I}$ be a basis of $M$.  Let $N$ be an $A$-module, and let $\{y_i\}_{i \in I}$ be a family of elements of $N$.  Then there exists a unique homomorphism $f: M \rightarrow N$ such that $f(x_i) = y_i$ for all $i$.

I bolded the key word: basis.  Earlier on that page Lang defines a basis, and says that a module which admits a basis is called free.  A basis is a much stronger condition than a generating set!  For any ring which is not a division ring, there will exist modules which do not have a basis, i.e., are not free.
The relation between this notion and the definition of projective goes in one direction: it shows that any free module is projective.  The converse is, in general, far from being true.  In fact determining when projective modules are free is quite a story: see e.g. $\S 3.5.4$ of my commutative algebra notes.
A: You cannot guarantee that $\psi$ is a module homomorphism, because the relations that hold in $P$ among the elements $u_i$ need not hold in $M$.
For a simple example, take $A=\mathbb{Z}$, and your proposed module $P$ the (non-projective) module $\mathbb{Z}/2\mathbb{Z}$. Let $M'' = P$, $f$ the identity, and let $M=\mathbb{Z}$ with $g\colon \mathbb{Z}\to\mathbb{Z}/2\mathbb{Z}$ the canonical projection.
Your proposal is: take a generating set for $P$; okay, I take $\{1+2\mathbb{Z}\}$. Then find some element in $M$ that maps to the image of $1+2\mathbb{Z}$; any odd $a\in\mathbb{Z}$ would work. Then you try to define $\psi$ by mapping $1+2\mathbb{Z}$ to $a$. But the only module homomorphism from $P$ to $\mathbb{Z}$ is the zero map, so no $\psi\colon P\to M$ maps $1+2\mathbb{Z}$ to a required pre-image. So this process does not work. The reason it does not work is that the potential preimages in $M$ don't satisfy the same relations that the $u_i$ do in $P$, in this case, that $1+2\mathbb{Z}$ satisfies $2(1+2\mathbb{Z}) = \mathbf{0}$. 
I don't have Lang in front of me, but I suspect that Theorem 4.1 is for free modules (as that is the only situation in which the theorem holds in that generality).
