Simple Html Dom Fatal error: Call to a member function on a non-object

Simple Html Dom is a PHP dom manipulator. This library is one of the easiest and most powerful dom manipulator for PHP. In fact, you can even use this to create your own web crawler like what i have done. However, Simple Html Dom library isn't perfect. Although you are able to do almost everything without a problem using simple htm dom, the most problematic thing that will happen in a complex program would be to have different combination of URL. The combination of a URL is endless and this can cause simple html dom to fail.

8 thoughts on “Simple Html Dom Fatal error: Call to a member function on a non-object

  1. Awesome post! I've spent hours trying to resolve this. How ever would it make more sense to use "||" (or) instead of "&&" (and)? Wouldn't you want your script to bail out if any of those conditions failed?

  2. because the condition was isset($html) instead of !isset($html). If it's !isset($html) everything will have to go for or conditional. my program was using or condition but the example up there i just use the opposite πŸ™‚

  3. Your cure to check that you received the $html works, how ever I still get the fatal error when doing a find(). It seems that if the find() function fails to find what you are looking for, it throws a fatal error which stops the script from running. Huge pain... Is there a way to further check the $html for let's say a certain table exists before calling the find() function?

  4. Thank you SO MUCH

    I have also spent way too long trying to figure this out. I had figured out the ifset and ifobject test but had not gotten to the ->nodes. AWESOME πŸ˜€

  5. Very helpful - been struggling with this for the past 48 hours. Managed to get the checking of $html and is_object in there, but the isset nodes thing must have been the key to it all. Thanks for doing this blog post man, it's people like you who make the internet invaluable!

  6. I'm facing this problem please help ?

    "I still get the fatal error when doing a find(). It seems that if the find() function fails to find what you are looking for, it throws a fatal error which stops the script from running. Huge pain… Is there a way to further check the $html for let’s say a certain table exists before calling the find() function?"

Comments are closed.