An upper bound for $E(\sup_{0\leqslant s\leqslant\tau}\|M_s\|^2)$, where $M$ is a square integrable martingale and $\tau$ a stopping time is given in terms of $\lbrack M\rbrack_{\tau^-}$ and $\langle M\rangle_{\tau^-}$. Counter examples show that $4E(\langle M\rangle_{\tau^-})$, which is easily derived as an upper bound from a classical Doob's inequality, when $\tau$ is predictable or totally unaccessible, is no longer an upper bound in general. The obtained majoration is used to prove existence and uniqueness of strong solutions of a stochastic equation $dX_t = a(t, X) dZ_t$, where $a$ is a functional, depending possibly on the whole past of $X$ before $t$, and $Z$ is a semimartingale. Our result thus extends to systems "with memory" recent results by Protter, Kazamaki, Doleans-Dade and Meyer.