troubleshooting Question

How can I fix this error?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
18 Comments2 Solutions250 ViewsLast Modified:
I'm using file_get_contents and file_put_contents in the context of an app that I'm building. I've been able to successfully get the content and write to a new html file, but when I go and try to retrieve the content from the page using loadHTML(), I'm getting an error and I'm not sure where it's coming from.

Here's my code:

if (file_get_contents('')) {
$datafile14 = file_get_contents('');
echo "Uploading Filename:\n";
echo "data has been uploaded!";
$html = file_get_contents('raw_html/crystal.html');

    /*** a new dom object ***/ 
    $dom = new domDocument; 

    /*** load the html into the object ***/ 
	echo "you've got a problem...!";

    /*** discard white space ***/ 
    $dom->preserveWhiteSpace = false; 

    /*** the table by its tag name ***/ 
    $tables = $dom->getElementsByTagName('table'); 

    /*** get all rows from the table ***/ 
    $rows = $tables->item(0)->getElementsByTagName('tr'); 

    /*** loop over the table rows ***/ 
    foreach ($rows as $row) { 
        /*** get each column by tag name ***/ 
$cols = $row->getElementsByTagName('td'); 

$enddate = $cols->item[0]->nodeValue;
$num_days = $cols->item[1]->nodeValue;
$area = $cols->item[2]->nodeValue;
$mmepool = $cols->item[3]->nodeValue;
$region = $cols->item[4]->nodeValue;
$vendor = $cols->item[5]->nodeValue;
$volte_ia_pcnt = $cols->item[6]->nodeValue;
$volte_lc_pcnt = $cols->item[7]->nodeValue;
$sip_mou = $cols->item[8]->nodeValue;
$volte_qci1_setup_failure_pcnt = $cols->item[9]->nodeValue;
$volte_qci1_setup_failures = $cols->item[10]->nodeValue;
$volte_qci1_setup_attempts = $cols->item[11]->nodeValue;
$qci5_setup_failure_pcnt = $cols->item[12]->nodeValue;
$qci5_setup_failures = $cols->item[13]->nodeValue;
$qci5_setup_attempts = $cols->item[14]->nodeValue;
$seer_pcnt = $cols->item[15]->nodeValue;
$seer_sip_ntwk_eff_calls = $cols->item[16]->nodeValue;
$seer_sip_call_attempts = $cols->item[17]->nodeValue;
$rrc_setup_failure_pcnt = $cols->item[18]->nodeValue;
$rrc_setup_attempts = $cols->item[19]->nodeValue;
$rrc_setup_failures = $cols->item[20]->nodeValue;
$volte_qci1_drop_pcnt = $cols->item[21]->nodeValue;
$volte_qci1_drops = $cols->item[22]->nodeValue;
$volte_qci1_established_calls = $cols->item[23]->nodeValue;
$qci5_bearer_drop_pcnt = $cols->item[24]->nodeValue;
$qci5_bearer_drops = $cols->item[25]->nodeValue;
$qci5_bearer_estab_calls = $cols->item[26]->nodeValue;
$volte_avg_mos = $cols->item[27]->nodeValue;
$volte_mos_numerator = $cols->item[28]->nodeValue;
$volte_mos_denominator = $cols->item[19]->nodeValue;
$volte_pdcp_dl_volume_mb = $cols->item[30]->nodeValue;
$volte_dl_volume_pcnt = $cols->item[31]->nodeValue;
$lte_pdcp_dl_volume_mb = $cols->item[32]->nodeValue;
$x7x24_volte_pdcp_dl_volume_mb = $cols->item[33]->nodeValue;
$x7x24_volte_dl_volume_pcnt = $cols->item[34]->nodeValue;
$x7x24_lte_pdcp_dl_volume_mb = $cols->item[35]->nodeValue;
$volte_pdcp_ul_volume_mb = $cols->item[36]->nodeValue;
$volte_ul_volume_pcnt = $cols->item[37]->nodeValue;
$lte_pdcp_ul_volume_mb = $cols->item[38]->nodeValue;
$x7x24_days = $cols->item[39]->nodeValue;
echo $x7x24_days;

The error I'm getting is: "Notice: Undefined property: DOMNodeList::$item in /opt/lampp/htdocs/crystal/test.php on line 37."

After that I get the expected parade of errors as my code tries to retrieve data from what is perceived as a "non-object."

What am I missing?
Join our community to see this answer!
Unlock 2 Answers and 18 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 18 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros