Skip to main content
PHP Bug Hunt Medium +20 XP

SQL Injection Risk

This query is vulnerable to SQL injection.

PHPFind the bug
1$id = $_GET["id"];
2$sql = "SELECT * FROM users WHERE id = $id";
The bug is on line 2

Select the correct fix

Show answer and explanation

Answer: Use prepared statements with PDO

Never interpolate user input into SQL. Use PDO prepared statements with bound parameters to prevent SQL injection.

Hint: User input should never go directly into SQL.

What this challenge tests

Bug Hunt in PHP: security, sql-injection.

Related challenges