Answer the question
In order to leave comments, you need to log in
Why is the wrong error thrown when using simple_html_dom?
There is such a code, it goes through the pages and collects information from each and saves it in the database.
For some reason, every time on the second iteration of the loop, the code gives the error
"Call to a member function find() on a non-object in C:\xampp\htdocs\zabor\oc-includes\simple-html\simple_html_dom.php on line 1112 "
Although the problem is in the line $item[$num]->add();
If you comment it out, then there will be no error and the code will normally pass through all iterations.
Tell me where to dig?
Below is the entire code.
while ($num) {
$url = 'http://some.url.com/category/' . $num;
$file_headers = @get_headers($url);
if ($file_headers[0] != 'HTTP/1.1 404 Not Found') {
$html = new simple_html_dom();
$html->load_file($url);
$info[] = (string)$html->find('.pricetitle')[0]->plaintext;
$data['price'] = intval(str_replace(',', '', $info[0])) * 1000000;
$item[$num] = new ItemActions();
$item[$num]->data = $data;
$item[$num]->add();
}else{
break;
}
$num++;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question