Menu

non-object error

2014-03-08
2014-03-09
  • Natalia Usselman

    Fatal error: Call to a member function query() on a non-object in /home/kelownae/public_html/admin/advanced_html_dom.php on line 31

    I have a simple file that loads all the links from Google.com. As soon as I replace the object and the include file to advanced_html_dom.php instead of simple_html_dom.php, I get above error.

    Can we have a sample file by any chance?

    This works:

    include('simple_html_dom.php');
    $html = new simple_html_dom();
    $html -> load_file('http://www.google.com/');
    

    This does not work:

    include('advanced_html_dom.php');
    $html = new AdvancedHtmlDom();
    $html -> load_file('http://www.google.com/');
    
     

    Last edit: Natalia Usselman 2014-03-08
    • P Guardiario

      P Guardiario - 2014-03-08

      I haven't added load_file yet, look for it in the next version, and for now try:
      $html = file_get_html('http://www.google.com/');

       
  • Natalia Usselman

    Then I get

    Catchable fatal error: Argument 2 passed to DOMXPath::query() must be an instance of DOMNode, null given, called in /home/kelownae/public_html/admin/advanced_html_dom.php on line 58 and defined in /home/kelownae/public_html/admin/advanced_html_dom.php on line 33

     
    • P Guardiario

      P Guardiario - 2014-03-09

      That happens when you try to query a null node. For example:
      $a = $html->find('a', 0);
      $img = $a->find('img', 0); // will fail if $a is null

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.