Alexander Andonov (Mordred) has written an articled called The Unexpected SQL Injection for the Web Application Security Consortium:
We will look at several scenarios under which SQL injection may
occur, even though mysql_real_escape_string() has
been used.
The focus of the article is stressing the importance of filtering
input and escaping output, as neither is a substitute for the
other, but he does so very clearly with specific examples that
include queries that use integer values (sans quotes),
user-supplied column names, LIMIT clauses, and
LIKE clauses. A number of example exploits are
supplied for …