Page 1 of 1

Warning: ereg(): REG_ECTYPE

Posted: Mon Sep 13, 2004 3:39 am
by kholloi
Hi.

I am trying to use a regular expression character class to vallidate an ip address.

Code: Select all

//check for valid ip address 
$oc = explode('.', $ip);
$nu = count($oc);

if ($nu!= 4)
{
 echo ("<br><br><br><h3>This is not a valid IP address, please try again!</h3>");
 exit;
 &#125;
 
 for ($i = 0; $i <= 4; $i++)
 &#123;
  if ($oc&#1111;$i] >= 256)
   &#123;
    echo ("<br><br><br><h3>This is not a valid IP address, please try again!</h3>");
    exit;
   &#125;
  elseif(!ereg('&#1111;&#1111;:digit]]+', $oc&#1111;$i]))
   &#123;
    echo ("<br><br><br><h3>This is not a valid IP address, please try again!</h3>");
    exit;
    &#125;
  &#125;
When I run the script I get this error:
Warning: ereg(): REG_ECTYPE in /srv/www/htdocs/admn/chif.php on line 40


This is line 40

Code: Select all

elseif(!ereg('&#1111;&#1111;:digit]]+', $oc&#1111;$i]))
What does the error mean? And can anyone see obvious mistakes?

THanks

Posted: Mon Sep 13, 2004 11:40 am
by feyd

Code: Select all

&#1111;&#1111;:digit:]]
try that.

Posted: Tue Sep 14, 2004 1:18 am
by kholloi
:oops:

Thanks