tags:

views:

51

answers:

1
<? $mysite = ('websiteurl');?>
<? echo $mysite; ?> Links not found
<?
  $time_limit = 3600;
  set_time_limit($time_limit);
  include_once("myconnect.php");
  $sql0="select * from trade where 1  ";
  $sql0=$sql0." order by a1 asc";
  $query=mysql_query($sql0);
  $cnt=1;
  while ( ($rs_query=mysql_fetch_array($query)) )
  { 
    if($cnt%2<>0)  
     $bgcolor="#EEEEEE";
    else  
     $bgcolor="#FFFFFF"; 
    $ok="";
    $page="";
    $page = @implode ('', @file ($rs_query["a2"]));
    if ($page)
    {
      if ( ereg("< *[a|A] +.*[h|H][r|R][e|E][f|F] *=.*(http://)?(www.)?(".$mysite.").*", $page) )
      {
        $ok="yes";
      }
      else
      {
        $ok="no";
      }
    }
    else
    {
      $ok="no";
    }
    if($ok=="no"){ echo $rs_query["a1"];}
  } 
?>
A: 

A problem might come from the "greedy matches" such as .* in your regex -- they will keep matching as much as they can, gobbling two tags where you thought only one was getting matched. Not sure if you can fix that in ereg, but then, aren't you supposed to use the more advanced preg since many years ago? With preg you can ask explicitly for a "lazy" (aka "non-greedy") match by using .*?, which might fix this issue (there may be others -- if you give us examples of problems you observe, it will be easier to help you debug!-).

Alex Martelli
Thanks, ill see what I can do, this is an old script ive had for a while.