Explain how prepared statements prevent SQL injection, and why is manual string escaping insufficient?
Last updated
Prepared statements send the SQL template with placeholders (
?or:name) to be parsed first. Values are bound separately, so input is always treated as data and never as SQL.Manual escaping fails easily: one forgotten variable is a vulnerability, charset mismatches can defeat it, and it doesn't protect unquoted contexts like numbers or
LIMIT.Parameters bind values only, not table or column names. Validate identifiers against an allowlist.