I'm having trouble with a regular expression.
I'm trying to use preg_match on a query string. I want it to exclude any sequence of drop or truncate regardless of the case (?i) that is between ' or ` and has any number of characters between the sequence and the two signs, but I want to catch any of those two words that is NOT between the two signs.
If you haven't guessed it yet, I want to detect whether or not an input is trying to DROP | TRUNCATE anything, but there is no easy way of doing that without excluding those words from non malicious input.
e.g.
I want this not to trigger:
SELECT * FROM `drop`
SELECT * FROM 'drop_truncate' -- drop drop
but this to trigger:
DROP TABLE `users`
EDIT: So my question was about regular expressions and I received answers on database security, no doubt there was something about the question that made you think that, sorry for misleading! No, I don't care about database security here for that I already handled, all I wanted here was to check for any INTENT of using either drop or truncate and log it somewhere. sigh