We help IT Professionals succeed at work.
Get Started

Why am I getting this "non-object" error?

Bruce Gust
Bruce Gust asked
on
276 Views
Last Modified: 2015-02-28
Head out to http://hihatwebdesign.com/test/volte.htm and you'll see the output of the code I have below.

I've got all sorts of stuff that I want to do as far as taking the contents of the referenced html file and inserting it into a database, but I can't get past a fatal error that you'll see when you out to the page I've got referenced above.

It starts at line 33 where it says you can't assign a property to a non-object and then it becomes lethal when the same "non-object" is accessed in the getElementsbyTagName.

When I output my html file, I get the data I'm expecting. But for some reason, my code isn't "seeing it" and I don't know why.

Why am I getting this "non-object" message and what do I need to do to fix it?

Here's my code in full, although the problem begins at line 33, so the rest, for right now, isn't relevant until I get this first mess cleaned up.

Thanks!

<?php
date_default_timezone_set('America/Chicago');
//I was getting some warnings on this page that seemed more about format then they did content. In an effort to keep it clean, yet accurate, I just activated "error_reporting(0)"
error_reporting(E_ALL);
ini_set('max_execution_time', 1200);
libxml_use_internal_errors(false);
require 'common.php';
echo 'STARTING PROCC VOLTE VOLTE 7 DAY TBL ' . date('h:i:s') . "<br>";


$html = file_get_contents('../uploads/volte_7day.html');
//var_dump($html);
$delete_query="delete from tbl_volte7";
//echo $delete_query;
$query_1 = mysqli_query($con, $delete_query);
if(!$query_1)
{
	echo "your delete query didn't work";
}

    /*** a new dom object ***/ 
    $file = new domDocument; 
	
	/*** load the html into the object ***/ 
	//introduced "@file" to suppress invalid HTML markup warnings
	$dom=@$file->loadHTML($html); 
	
	if(!$dom)
	{
		echo "You don't have data";
	}
	    /*** 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;


$ran_ia_pcnt = $volte_qci1_setup_failure_pcnt + $qci5_setup_failure_pcnt + $rrc_setup_failure_pcnt ;
$seer_ia_pcnt = 100 - $seer_pcnt;


if ($region == 'Carolinas/Tennessee') {$region = 'CAR/TN';}
if ($region == 'Central Texas') {$region = 'CTX';}
if ($region == 'Florida') {$region = 'FL';}
if ($region == 'Georgia/Alabama') {$region = 'GA/AL';}
if ($region == 'Houston/Gulf Coast') {$region = 'HGC';}
if ($region == 'South Central') {$region = 'SCTL';}

if ($enddate <> '' ){
$q1 = "insert into tbl_volte7(enddate,latest_date,area,region,vendor,ran_ia_pcnt,seer_ia_pcnt,volte_lc_pcnt,sip_mou,volte_qci1_setup_failure_pcnt,volte_qci1_setup_failures,volte_qci1_setup_attempts,qci5_setup_failure_pcnt,qci5_setup_failures,qci5_setup_attempts,seer_pcnt,seer_sip_ntwk_eff_calls,seer_sip_call_attempts,rrc_setup_failure_pcnt,rrc_setup_attempts,rrc_setup_failures,volte_qci1_drop_pcnt,volte_qci1_drops,volte_qci1_established_calls) VALUES ('$enddate','$latest_date','$area','$region','$vendor','$ran_ia_pcnt','$seer_ia_pcnt','$volte_lc_pcnt','$sip_mou','$volte_qci1_setup_failure_pcnt','$volte_qci1_setup_failures','$volte_qci1_setup_attempts','$qci5_setup_failure_pcnt','$qci5_setup_failures','$qci5_setup_attempts','$seer_pcnt','$seer_sip_ntwk_eff_calls','$seer_sip_call_attempts','$rrc_setup_failure_pcnt','$rrc_setup_attempts','$rrc_setup_failures','$volte_qci1_drop_pcnt','$volte_qci1_drops','$volte_qci1_established_calls')";
echo $q1;
$insert = mysqli_query($con, $q1) ;
if(!$insert)
{
	echo "your insert query didn't happen";
}

}
} 


$q2 = "select avg(ran_ia_pcnt) as area_ran_ia_pcnt, avg(seer_ia_pcnt) as area_seer_ia_pcnt, (sum(volte_qci1_drops)/sum(volte_qci1_established_calls))*100 as area_volte_lc_pcnt, sum(sip_mou) as area_sip_mou  from tbl_volte7"; 
//echo $q2  . "<br>";
$r2 = mysql_query($q2) or die(mysql_error()); 
$row1 = mysql_fetch_assoc($r2);


$area_ran_ia_pcnt = round($row1['area_ran_ia_pcnt'],3);
$area_seer_ia_pcnt = round($row1['area_seer_ia_pcnt'],3);
$area_volte_lc_pcnt = round($row1['area_volte_lc_pcnt'] ,3);
$area_sip_mou = $row1['area_sip_mou'];

$q3 = "insert into tbl_volte7 set region = 'AREA', ran_ia_pcnt = '$area_ran_ia_pcnt', seer_ia_pcnt= '$area_seer_ia_pcnt', volte_lc_pcnt = '$area_volte_lc_pcnt', sip_mou = '$area_sip_mou' "; 
//echo $q2  . "<br>";
$insert_2=mysqli_query($con, $q3);
if(!$insert_2)
{
	echo "your averages didn't work";
}

mysql_close($con); 
 
echo 'COMPLETED PROCC VOLTE 7 DAY TBL ' . date('h:i:s') . "<br>";

 

?> 

Open in new window

Comment
Watch Question
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This problem has been solved!
Unlock 4 Answers and 17 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE