-1

In my UI there is a text area that has a list of URLs separated by new line.

I am getting this into a string and exploding it using newline character. I am getting this error:

Fatal error: Call to a member function find() on a non-object in C:\xampp\htdocs\apps\lt\track-them.php on line 34

$myurl       = "http://mydomain.com/testpage1.html";
$str         = "http://www.domain.com/page1.html
http://www.homepage.com/page2.html
http://www.internet.com/index.html";

$backlinkarr = explode("\n", $str);
echo '<table border=1>';
foreach ($backlinkarr as $backlinkitem) {
    $backlinkitem = trim($backlinkitem);
    $LinkCount    = 0;
    $html         = file_get_html($backlinkitem);
    foreach ($html->find('a') as $link) {
        if ($link->href == $myurl) {
            $LinkCount += $LinkCount + 1;
        }
    }
    echo $backlinkitem . ' (' . $linkCount . ')';
}
hakre
  • 193,403
  • 52
  • 435
  • 836
ozzboy
  • 2,672
  • 8
  • 42
  • 69

1 Answers1

0

on windows new line is \r\n

also, your error suggests that $html is not an object, meaning previous line fails. so, debug there with var_dump($backlinkitem) if it is correct and also you can use file_exists to verify if that file actually exists.

jancha
  • 4,916
  • 1
  • 24
  • 39
  • Thanks. I think it was due to "\r\n". I changed the line $backlinkarr = explode("\r\n", $str); and its working fine. Thanks. – ozzboy Sep 22 '11 at 14:23