need help to find error in php script

Discussion in 'Programming' started by ssimon171078, Jan 9, 2015.

  1. #1
    i write parser for seoclerks.com i need help to fix error:
    Parse error: syntax error, unexpected end of file in C:\wamp\www\ebay\d2.php on line 38
    my script:

    <?php
    // parser of website seoclerks.com


    $website="https://www.seoclerk.com/page/";
    $filename="links_seoclerks1_3.txt";
    $fd=fopen($filename,"w");
    function parse($Page)
    {
    global $website;
    global $filename;
    //if ($Page!=0)
    $content=file_get_contents($website."/$Page?s=t");
    //echo ($content)."<br>";
    $stripped_file = strip_tags($content, "<a>");
    preg_match_all("/<a[\s]+[^>]*?href[\s]?=[\s\"\']+"."(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/", $stripped_file, $matches, PREG_SET_ORDER );
    print_r($matches);
    foreach($matches as $match){
    $href=$match[1];
    $pos =strpos ($href,"Other") ||strpos ($href,"Accounts") || strpos ($href,"Article-Translating") ||strpos ($href,"Article-Writing") || strpos ($href,"Banner-Ads") ||strpos ($href,"body-ads") || strpos ($href,"lists") || strpos ($href,"lists") || strpos ($href,"design") || strpos ($href,"directory-submission") ||strpos ($href,"Graphics") || strpos ($href,"Social-Networks") || strpos ($href,"facebook") || strpos ($href,"google-marketing") || strpos ($href,"Instagram") || strpos ($href,"Traffic") || strpos ($href,"youtube") ;
    $pos2=strpos ($href,"wantcats") || strpos ($href,"tradecats") || strpos ($href,"categories") ;
    if($pos!=0 && $pos2 ==0){
    fwrite($fd,$stripped_file);
    fwrite($fd,"\n");

    }



    for ($Page=1;$Page<20;$Page++){
    parse($Page);

    }
    fclose($fd);

    ?>
     
    ssimon171078, Jan 9, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Cleaned up the code, fixed your errors - neither the function, nor the foreach was closed - use a proper parser / editor, and you'll see those errors right away.
    And, if you paste code into the forum again, please put the code in code-tags?
    
      <?php
      // parser of website seoclerks.com
      function parse($Page) {
      $website = 'https://www.seoclerk.com/page/';
      $filename = 'links_seoclerks1_3.txt';
      $fd = fopen($filename,'w');
      $content = file_get_contents($website.'/'.$Page.'?s=t');
    
      $stripped_file = strip_tags($content, '<a>');
      preg_match_all("/<a[\s]+[^>]*?href[\s]?=[\s\"\']+"."(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/", $stripped_file, $matches, PREG_SET_ORDER );
      print_r($matches);
      foreach($matches as $match) {
      $href = $match[1];
      $pos =  strpos($href,'Other') ||
      strpos($href,'Accounts') ||
      strpos($href,'Article-Translating') ||
      strpos($href,'Article-Writing') ||
      strpos($href,'Banner-Ads') ||
      strpos($href,'body-ads') ||
      strpos($href,'lists') ||
      strpos($href,'lists') ||
      strpos($href,'design') ||
      strpos($href,'directory-submission') ||
      strpos($href,'Graphics') ||
      strpos($href,'Social-Networks') ||
      strpos($href,'facebook') ||
      strpos($href,'google-marketing') ||
      strpos($href,'Instagram') ||
      strpos($href,'Traffic') ||
      strpos ($href,'youtube');
      $pos2 = strpos($href,'wantcats') ||
      strpos($href,'tradecats') ||
      strpos($href,'categories');
       
      if ($pos !=0 && $pos2 == 0) {
      fwrite($fd,$stripped_file);
      fwrite($fd,"\n");
      }
      }
      }
    
      for ($Page = 1; $Page < 20; $Page++) {
      parse($Page);
      }
    
      fclose($fd);
      ?>
     
    Code (markup):
     
    PoPSiCLe, Jan 9, 2015 IP