xaviermontenegro

Untitled

Jul 25th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. // This is functionally equivalent...
  2. $query = $pdo->query("SELECT foo FROM bar WHERE id = {$_GET['id']}");
  3. $results = $query->fetchAll();
  4.  
  5. // To this
  6. $query = $pdo->prepare("SELECT foo FROM bar WHERE id = :id");
  7. $query->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
  8. $query->execute();
  9. $results = $query->fetchAll();
  10.  
  11. // except the first one is not protected against sql injections at all
Add Comment
Please, Sign In to add comment