Created
July 1, 2013 15:24
-
-
Save scottsappen/5901807 to your computer and use it in GitHub Desktop.
PHP MySQL PDO sql injection safety
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$pdo = new PDO('mysql:dbname=your_database;host=localhost', $username, $password); | |
//don't use whatever the user typed in, use a variable | |
$stmt = $pdo->prepare('SELECT * FROM MyGuestBook WHERE firstName = :firstName'); | |
//that variable is then assigned to whatever the user typed in, but it's escaped and treated safely | |
$stmt->execute(array(':firstName' => $firstName)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment