I know "parameterised queries" is the holy grail. This is not the topic.
There is an old post, that seems to be the reference for all discussions related to sql injections when addslashes is used.
This is the link : http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string
My question is : is this Proof of concept still correct ? I tried to test it but the addslashes seems to be working correctly. Did anyone else actually tried this or everybody is taken it for granted ?
I added $db->set_charset("GBK");
I used gbk_chinese_ci for db/fields
The mysql log shows this query
SELECT *
FROM users
WHERE username = '?' OR username = username /*'
AND password = 'guess'
so clearly the trick it's not working
Update : Please read the question I'm asking.
I don't care for best practice, I don't need alternatives, I just need to makes sure this is still valid or not.
Update : Also I would like to remind this POC works for character sets like GBK, SJIS or BIG5 and everybody seems to forget that. Making the titles sound a bit to scary when saying addslashes is not safe.
Solution : In my case the mysql version 5.5.9-log is not allowing inline comments that are not finised like /*. If I use -- or # it works.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…