← PHP / Laravel · Contents

PHP-001 / Beginner

SQL injection: concatenating query strings

A03:2021 Injection · CWE-89 SQL Injection

Why is this a problem?

User input becomes part of the SQL syntax, allowing conditions to be bypassed and data to be leaked or modified.

How to fix it

php
$rows = DB::select('SELECT * FROM users WHERE email = ?', [$email]);

Further reading