note 91266 deleted from security.database.sql-injection by googleguy

From: Date: Tue, 22 Oct 2013 12:18:12 +0000
Subject: note 91266 deleted from security.database.sql-injection by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197161@lists.php.net to get a copy of this message
Note Submitter: Quietust ---- An anonymous comment below suggests using PEAR with prepare() / execute() - though it was posted 3 years ago, it is still true today, though it's even easier now since PDO is included in most distributions. For SET/WHERE clauses and INSERT statements, just prepare the query with question marks in place of the dynamic parameters, bind each value in, then execute it, and it'll do all of the escaping for you, rendering the query immune to injection. Dynamic substitution of ORDER BY or LIMIT clauses has to be done the old fashioned way, though, so you still need to be careful with those. Even without PDO, if you're using Postgres, you've already got the means to use parameterized queries, and if you're using MySQL, you simply need to ignore the outdated "mysql" extension and use "mysqli" instead.

« previous php.notes (#197161) next »