code_junkie

How is this MySQL query vulnerable to SQL injection?

Nov 12th, 2011
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. select
  2. ss.*,
  3. se.name as engine,
  4. ss.last_run_at + interval ss.refresh_frequency day as next_run_at,
  5. se.logo_name
  6. from
  7. searches ss join search_engines se on ss.engine_id = se.id
  8. where
  9. ss.user_id='.$user_id.'
  10. group by ss.id
  11. order by ss.project_id, ss.domain, ss.keywords
  12.  
  13. $db_connection = new mysqli("localhost", "user", "pass", "db");
  14. $statement = $db_connection->prepare("SELECT thing FROM stuff WHERE id = ?");
  15. $statement->bind_param("i", $user_id); //$user_id is an integer which goes
  16. //in place of ?
  17. $statement->execute();
Add Comment
Please, Sign In to add comment