Warning: preg_match(): Unknown modifier

Links for php scripts

Moderators: gesf, Michalio

Post Reply
countrydj

My script did work at one time, but it doesn't now.
This is the line that is throwing a wobbly:
if(preg_match("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $from)) {
I cannot see or find what is cousing the problem. This is the error message:
Warning: preg_match(): Unknown modifier '(' in /home/ukzone/in-uk.uk/html/calendar/register-exec.php on line 205
Can anybody help me with this problem?
Thanks,

John C
hyper

Are you sure

Code: Select all

if(preg_match("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $from)) {
is line 205?
countrydj

YES.
That is definately line 205.
It is a long script used for accepting input from the form. Then the script sends an email to ME ($from). that email is then returned with the validation.
This is when I get the error message.
I have to say though, that it wasn't always faulty. The script did work originally, but I cant remember whar I got the script from so I can't check it.
countrydj

I forgot to mention that if I replace the above code with:

Code: Select all

if(preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $from)) {
The script does work.
hyper

Syntactically, that line is correct.

If this is for checking an email address, you might want to change it to:

Code: Select all

filter_var($email, FILTER_VALIDATE_EMAIL)
Unget1942

I am happy I have discovered your post. I was perusing audits on pay to write essay and keeping in mind that perusing audits on the web, I have discovered your post. I have an application yet I am not getting numerous guests on my application so I am pondering creating it.
hyper

I'd be happy to write about spam, spammers and spam posts, how does that sound. I'm sure that I could knock up 500 words, or more, or less whatever to suit your supposed criteria.
simonbrahan

Your regular expression must be "delimited" by a pair of characters. Some examples are "/", "#", and "[" "]". Noarmlly I use "/" as it doesn't clash with other regex syntax. Replace your pattern with this:

Code: Select all

/([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)/
Note the "/" at the start and end.
Post Reply