Jump to content
yasdevelopment

PHP Fatal error: Call to a member function find() on boolean

Recommended Posts

PHP Fatal error: Call to a member function find() on boolean line 85

 

$search = urlencode($title);                
        $html = file_get_html("http://www.letmewatchthis.pl/?tv=&search_keywords=$search&search_section=2");
        $elements = $html->find(".index_item h2");
        if(!is_null($elements)){

85 is $elements = $html ->find

 

Share this post


Link to post
Share on other sites

 What is this "file_get_html" function?  I don't see it in the official php manual.

Share this post


Link to post
Share on other sites

Google.

 

It's an abandoned, buggy, useless HTML library which, for some strange reason, has gained popularity among newbies. The solution is simple:

  1. Throw away the library and switch to one of the PHP HTML extensions like DOM. You can use XPath to search for elements.
  2. Turn your error reporting all the way up and either log the errors (in production) or display them on the screen (during development).
  3. Read the manual and learn to handle errors. When a function may return false in case of an error, you need to actually cover that case.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.