Complete the code to select user data by username safely.
SELECT * FROM users WHERE username = '[1]';
The username should be a simple string like 'admin' to avoid SQL injection.
Complete the code to prevent SQL injection by using parameter placeholders.
SELECT * FROM users WHERE username = [1];Using a parameter placeholder like '?' helps prevent SQL injection by separating code from data.
Fix the error in the query that allows SQL injection.
SELECT * FROM users WHERE username = '[1]';
Only a simple username like 'admin' avoids injection. The others inject extra SQL commands.
Fill both blanks to safely check username and password using parameters.
SELECT * FROM users WHERE username = [1] AND password = [2];
Use placeholders like '?' and named parameters like ':password' to prevent injection.
Fill all three blanks to create a safe query that filters users by role and status.
SELECT * FROM users WHERE role = [1] AND status = [2] AND active = [3];
Use a safe string for role, a placeholder for status, and a boolean TRUE for active.