SQL injection

An attack where text typed into a form is run as part of a database query.

Also called: SQLi

Type
Term
Source
General
Languages
SQL, PHP

In plain English

It happens when user input is glued into SQL as text. The fix is always the same: prepared statements (or an ORM that uses them), never string concatenation.

Example

The old plugin glued the search text into the query, a textbook SQL injection.

In code

// dangerous
$db->query("SELECT * FROM users WHERE email = '$email'");
// safe
$stmt = $pdo->prepare('SELECT * FROM users WHERE email = ?');
$stmt->execute([$email]);

Related terms

Added 2026-11-30 · Last reviewed 2026-11-30