0

Anyone knows why I have this error? What am I doing wrong?

<?
include('simple_html_dom.php');

$html = ("http://99designs.pt/logo-design/contests?show=finished");
foreach($html->find('span[class=active.sl_notranslate]') as $aholder) {

echo $aholder . '<br>';
}
?>

Fatal error: Call to a member function find() on a non-object in ../simplehtml.php on line 5

2
  • 2
    In this instance $html is a string so it won't have any methods attached to it. Commented Nov 2, 2014 at 23:59
  • thanks, It was missing this: $html = file_get_html($url); Do you know how I echo the "span" content? Commented Nov 3, 2014 at 0:04

1 Answer 1

1

You forgot to add the function name file_get_html, the code should be like this:

<?php
  include 'simple_html_dom.php';

  $html = file_get_html("http://99designs.pt/logo-design/contests?show=finished");
  foreach($html->find('span[class=active.sl_notranslate]') as $aholder) {

    echo $aholder . '<br>';
  }

?>
Sign up to request clarification or add additional context in comments.

4 Comments

To echo the span content you should put this code inside the foreach echo $aholder->innertext . '<br>'; Check the documentation here: simplehtmldom.sourceforge.net, it is very well exaplined.
I add that, but is returning nothing... The content of the span is from the data base of the website. Is that the problem? On console I have this error: "GET js.bizographics.com/insight.min.js net::ERR_BLOCKED_BY_CLIENT "
no, the console doesn`t have anything with this. i checked the source of the url which you provided but there is no span with .sl_notranslate class.
you are right. It's not "active.sl_notranslate". It's "active sl_notranslate". I got it, thanks :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.