0

I'm trying to get the latest status (in this case "Shipment delivered in good condidtion") of a TNT parcel but am unable to parse the external html using simple html dom. Getting Fatal error: Call to a member function find() on a non-object on line 6

<?php 
include("simple_html_dom.php");

$html = file_get_html('http://www.tnt.com/webtracker/tracking.do?&cons=323626321');

$e=$html->find('table.appTable', 1)->find('tr[valign=top]', 0)->find('td', 3);

echo $e;
?> 

even the sample code from http://simplehtmldom.sourceforge.net/index.htm gives me the same error

<?php
$html = file_get_html('http://www.google.com/');
foreach($html->find('img') as $element) 
   echo $element->src . '<br>';
?>

What am I doing wrong?

vincchan
  • 1
  • 1

1 Answers1

0
 file_get_html 

use

 file_get_contents

to read html page from url. You need to make sure this function is not blocked. In your case it seems that it was

 allow_url_fopen = Off

in php.ini which blocked it.

But any way, it is better to use a

 if ($html)

to become sure everything goes good before doing any thing.

Soroush Falahati
  • 2,196
  • 1
  • 27
  • 38