views:

132

answers:

2

Im using eregi() function for matching the string but it is giving the following error :-

PHP Warning:  eregi() [<a href='function.eregi'>function.eregi</a>]: REG_EPAREN in /a/b/c/mysite/file.php on line 59, referer: xyz.com

im using this function here :-

if(eregi($check,$in))
{
    $titles=ucfirst(substr($desc, 0, 38));
}
else
{
    $titles=$title." : ".$add_desc;
}

where $check & $in is containing text type data which can be anything from alphanumeric to special characters.

what could be the possible reason for this error and how to fix it ??

+1  A: 

Since eregi does a 'case insensitive regular expression match' $check should contain a valid regular Expression, not just 'text type data'. You should probably use stristr instead.

Huppie
A: 

The problem seems to be that $check contains characters that mess up the regular expression. If you can, cou should move to the preg_* regular expression functions and run $check through preg_quote.

if(preg_match(preg_quote($check), $in)) ...
Stefan Gehrig