Both posts include things you should look at using in conjunction with any database work you do. However, I believe what you want is to use Regular Expressions (RegEx) to determine whether or not someone has used illegal characters in your variables (you could use 'ctype_alnum()' if you didn't want the square brackets to be legal characters []) .
In ctype_alnum you are only allowed 0-9, a-z and A-Z. Anything other than this (even a blank space --> <--) is illegal and will cause the function to return false.
However, if you NEED to have square brackets in the variables then it is best you use regular expression. This is something that is common to most languages though sadly it's not my strong point. The website below will help detail how it works;
http://www.regular-expressions.info/
You would then need to use the PHP ereg() function to search a string for illegal characters.
Anyone else...?
Last edited by EdB; 05-26-2009 at 07:53 AM..
|