I understand that using PDO makes SQL injections virtually impossible. However, I don't have time at the moment to change all the database related code in our website. (Especially since I'm new at PDO, there's some learning curve involved). So I want to know what mysql/php functions will give the same security that PDO does.
Will these two points be enough?
- Making sure all $_GET and $_POST data are of the type expected (such as product ids should only be numerical, so I could use
is_numeric
). - Using
mysql_real_escape_string
.
Or is there anything else I should do? The way the website is, is that based on id=x
in the query string, things might go to the database. And what I saw after the hack was that in the database, all things that can go to the database through query strings had been compromised with values like cd etc/pwd
.