Hello,

Please help me to fix 2 php errors. Thank you.

Error 1

PHP Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /var/www/html/site3/check.php

$targetAddra = "209.107..*..*";
if (preg_match($targetAddra, $_SERVER['REMOTE_ADDR'])) {
die;
} 

Error 2

PHP Notice: Undefined offset: 2 in /var/www/html/site3/functions.php on line 105" while reading upstream...

Line 105 is this:

$bd=$val[0].$val[1].$val[2];

function mysql2data($sqldata,$b=NULL) {
   global $wmm;
   $sqldata=str_replace(' ','-',$sqldata);
   $val = explode('-', $sqldata);
   if($b==NULL) {
      $data= substr($wmm[intval($val[1])],0,3).' '.$val[2].' '.$val[0];
   } else {
   $bd=$val[0].$val[1].$val[2];
   $dat=date("Ymd",time());
   $data=intval(($dat - $bd) / 10000);
   }
   return $data;
}

    A PCRE regular expression must be surrounded by an arbitrary delimiter (and optionally followed by modifiers), so it would need to be something like:

    $targetAddra = "/209.107..*..*/";
    // or //
    $targetAddra = "#209.107..*..*#";
    

    Also note that "." is a special character meaning "any character, so if any of those are literal periods (full stops), then you need to escape them with a back-slash, such as:

    $targetAddra = "/209\.107\..*\..*/";
    

    But without knowing your exact search criteria, I do not know if that is what you need or if it is complete enough (I doubt it).

      Thanks, NogDog. This works:

      $targetAddr = "/209.107..+/";

      Do you have some idea how to fix the second error "undefinied offset"?

      I just decided to get rid of error/warning messages instead of hiding them.

      Thanks.

        The undefined offset error simply means there is not array element with that index. Presumably your call to explode() only found two elements (i.e. there was only one "-"), so the only array indexes were 0 and 1.

          Write a Reply...