when this function was called it gave the message
Warning: preg_match() [function.preg-match]: No ending delimiter '/'
this is the function to check for alphanumeric input
function CheckAlphanumeric($element,$minlength,$maxlength)
{ if (!preg_match ("/[^A-Za-z\s\0-9 - @ .]//", $element) && strlen($element)>=$minlength && strlen($element) <=$maxlength) { return TRUE; }
else { return FALSE;}
}
What are your inputs on this warning?
Best Answer
You'll want to escape the last forward slash (or remove it, not sure if it should be in that regex?). Also, you have a backslash before the 0 which doesn't really make sense either.
or
or
Also, did you know you can use a
[:alnum:]
shortcut? (src)Hopefully final edit:
I'd suggest you take a look at your function in the first place too, it's a bit confusing. You essentially want to check against three conditions, 1) does it pass regex, 2) is it gte the min length, and 3) is it lte the max length. Since all three of these return booleans (or things that evaluate correctly as booleans), you can simplify the function as follows: