jerrylmclaughlin
asked on
eregi not working as expected
Hello -
I have the code below
if(!eregi("^([0-9a-z-])+$" , $subaddr1)){
$custerror->c_error("sessi on.php", "430","Addr1 is not alphanumeric");
$form->setError($field, "* Address1 not alphanumeric");
}
if I set $subaddr1= '4404 Normandy Ave'
the if statement evaulates to true and executes the error functions
Why?
I have the code below
if(!eregi("^([0-9a-z-])+$"
$custerror->c_error("sessi
$form->setError($field, "* Address1 not alphanumeric");
}
if I set $subaddr1= '4404 Normandy Ave'
the if statement evaulates to true and executes the error functions
Why?
if (!eregi('^([a-z0-9[:space: ]]+)$', $subaddr1)) {
$custerror->c_error("sessi on.php", "430","Addr1 is not alphanumeric");
$form->setError($field, "* Address1 not alphanumeric");
}
$custerror->c_error("sessi
$form->setError($field, "* Address1 not alphanumeric");
}
if(!eregi("^([\w[:space:]] )+$", $subaddr1)){
$custerror->c_error("sessi on.php", "430","Addr1 is not alphanumeric");
$form->setError($field, "* Address1 not alphanumeric");
}
or
if(!eregi("^([\w\s])+$", $subaddr1)){
$custerror->c_error("sessi on.php", "430","Addr1 is not alphanumeric");
$form->setError($field, "* Address1 not alphanumeric");
}
$custerror->c_error("sessi
$form->setError($field, "* Address1 not alphanumeric");
}
or
if(!eregi("^([\w\s])+$", $subaddr1)){
$custerror->c_error("sessi
$form->setError($field, "* Address1 not alphanumeric");
}
Oh! Sorry! This:
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ------
if(eregi("^([\w[:space:]]) +$", $subaddr1)){
$custerror->c_error("sessi on.php", "430","Addr1 is not alphanumeric");
$form->setError($field, "* Address1 not alphanumeric");
}
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ------
or this:
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ------
if(eregi("^([\w\s])+$", $subaddr1)){
$custerror->c_error("sessi on.php", "430","Addr1 is not alphanumeric");
$form->setError($field, "* Address1 not alphanumeric");
}
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ------
--------------------------
if(eregi("^([\w[:space:]])
$custerror->c_error("sessi
$form->setError($field, "* Address1 not alphanumeric");
}
--------------------------
or this:
--------------------------
if(eregi("^([\w\s])+$", $subaddr1)){
$custerror->c_error("sessi
$form->setError($field, "* Address1 not alphanumeric");
}
--------------------------
ASKER
I will try these solutions, but know one answered my question. Why isn't that simple pattern in eregi not working?
It should work as is?
It should work as is?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you tolagong and gicutza_cj
Angel III yours did not work, I assuming its due to the missing ! in front of the eregi
Angel III yours did not work, I assuming its due to the missing ! in front of the eregi
if(eregi("^([0-9a-z ])+", $subaddr1)){
$custerror->c_error("sessi
$form->setError($field, "* Address1 not alphanumeric");
}