Bruce Gust
asked on
Why am I getting this "non-object" error?
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!
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>";
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Again: $dom is just a boolean value.
Use $file->preservewhitespace and $table = $file->getelementsbytagnam e... and it should work
Use $file->preservewhitespace and $table = $file->getelementsbytagnam
ASKER
Guy! We're making progress!
I was finally able to figure out what you meant by a "boolean" value. Just to make sure I'm tracking with you, "boolean" isn't data as much as it's a declaration as to whether or not something is or isn't, often expressed as either True or False.
That being the case, because of the way I had things set up, I was looking for data in a "True" and that's not going to fly.
Still not out of the woods, though...
Everything is swimming along until I actually start trying to retrieve data and I'm still stuck. Check it out:
I've done a "if($tables) echo "we've got data"; } and confirmed some kind of digital presence with tables, rows and columns. But when I get to $enddate=$cols->item(0)->n odeValue, I get:
Trying to get property of non-object in /var/www/html/sasite/weekl y_reports/ procedures /procc_vol te_7day.ph p on line 46
So, I'm still blowing it somewhere. Any ideas?
I was finally able to figure out what you meant by a "boolean" value. Just to make sure I'm tracking with you, "boolean" isn't data as much as it's a declaration as to whether or not something is or isn't, often expressed as either True or False.
That being the case, because of the way I had things set up, I was looking for data in a "True" and that's not going to fly.
Still not out of the woods, though...
Everything is swimming along until I actually start trying to retrieve data and I'm still stuck. Check it out:
$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 ***/
$file->preserveWhiteSpace = false;
/*** the table by its tag name ***/
$tables = $file->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;
I've done a "if($tables) echo "we've got data"; } and confirmed some kind of digital presence with tables, rows and columns. But when I get to $enddate=$cols->item(0)->n
Trying to get property of non-object in /var/www/html/sasite/weekl
So, I'm still blowing it somewhere. Any ideas?
that means that either $cols or $cols->item(0) is not an object ....
ASKER
When I do a var_dump($cols), I get this:
" object(DOMNodeList)#8 (1) { ["length"]=> int(0) }
This killing me, Guy! When I do if($cols){echo "you've got data";}, I get "you've got data." But then after doing a var_dump, it doesn't look like I've got squat and I don't even know where to start to figure out what I have, if I've got anything.
What's the next move?
" object(DOMNodeList)#8 (1) { ["length"]=> int(0) }
This killing me, Guy! When I do if($cols){echo "you've got data";}, I get "you've got data." But then after doing a var_dump, it doesn't look like I've got squat and I don't even know where to start to figure out what I have, if I've got anything.
What's the next move?
var_dump($cols) is giving you some data -- an object with one property named "length." That's enough for PHP to account for a truthy type juggle. PHP is loosely typed and therefore the double-equal comparisons may not always tell you all of the information you need. Some further explanation here:
http://php.net/manual/en/language.types.type-juggling.php
http://php.net/manual/en/types.comparisons.php
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12310-PHP-Variables-and-References.html
In the instant case, you probably want to be testing the return values from each function call. You may visualize these with var_dump() to see what you're getting.
If you want to post a sample of the data you're working with and an example of the data you're trying to pull out, we may be able to help you make the conversion.
http://php.net/manual/en/language.types.type-juggling.php
http://php.net/manual/en/types.comparisons.php
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12310-PHP-Variables-and-References.html
In the instant case, you probably want to be testing the return values from each function call. You may visualize these with var_dump() to see what you're getting.
If you want to post a sample of the data you're working with and an example of the data you're trying to pull out, we may be able to help you make the conversion.
ASKER
Morning, Ray! As always, I appreciate your time and willingness to weigh in! I'm hoping that what I'm about to give you represents the sample of the data that you're looking for.
http://hihatwebdesign.com/test/volte.htm is the data. That html file and the info you see there is the information my code is trying to retrieve and put into a database.
This project / app was written by another very capable developer. The challenge, however, is that it was written in a deprecated version of PHP. So when I brought it over to my server, I was getting all kinds of errors (he was using mysql as opposed to mysqli) and what I thought was going to be a 15 minute copy and paste has become far more challenging.
Still, I want to hope that the architecture is sound, it's just a matter of knowing what to look for and updating things accordingly.
Having said all that, I'm hoping you've got enough info to be able to decipher my dilemma and give me some suggestions. In a minute, I'm going to post the original code that is working on his server even as we speak. And then I'll post my code with some comments that show you where I've made some changes and perhaps that will give you a better idea of where I'm missing something.
Happy Saturday!
http://hihatwebdesign.com/test/volte.htm is the data. That html file and the info you see there is the information my code is trying to retrieve and put into a database.
This project / app was written by another very capable developer. The challenge, however, is that it was written in a deprecated version of PHP. So when I brought it over to my server, I was getting all kinds of errors (he was using mysql as opposed to mysqli) and what I thought was going to be a 15 minute copy and paste has become far more challenging.
Still, I want to hope that the architecture is sound, it's just a matter of knowing what to look for and updating things accordingly.
Having said all that, I'm hoping you've got enough info to be able to decipher my dilemma and give me some suggestions. In a minute, I'm going to post the original code that is working on his server even as we speak. And then I'll post my code with some comments that show you where I've made some changes and perhaps that will give you a better idea of where I'm missing something.
Happy Saturday!
ASKER
First off, here's the original code that is currently operating without a problem:
Secondly, here is the code that I've edited in order to update the deprecated mysql stuff along with some comments to explain where I've been making some changes:
I've got the html file that's referenced in the code attached.
volte-7day.html
<?php
#!/usr/bin/php
//error_reporting(0);
ini_set('max_execution_time', 1200);
require '/opt/lampp/htdocs/saweb/sysperf/common.php';
echo 'STARTING PROCC VOLTE VOLTE 7 DAY TBL ' . date('h:i:s') . "<br>";
$html = file_get_contents('/opt/lampp/htdocs/upload/volte_7day.html');
mysql_query('delete from tbl_volte7');
/*** a new dom object ***/
$dom = new domDocument;
/*** load the html into the object ***/
$dom->loadHTML($html);
/*** 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')";
mysql_query($q1) ;
}
}
$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>";
mysql_query($q3);
mysql_close($con);
echo 'COMPLETED PROCC VOLTE 7 DAY TBL ' . date('h:i:s') . "<br>";
?>
Secondly, here is the code that I've edited in order to update the deprecated mysql stuff along with some comments to explain where I've been making some changes:
<?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);
//made sure that the "common.php" file was accurately point to, and connecting with, my database
require 'common.php';
echo 'STARTING PROCC VOLTE VOLTE 7 DAY TBL ' . date('h:i:s') . "<br>";
//here's the data I'm trying to retrieve. I'll send this in another post
$html = file_get_contents('../uploads/volte_7day.html');
var_dump($html);
$delete_query="delete from tbl_volte7";
//echo $delete_query;
//line 16 shows you what I had to do to bring the code up to a more contemporary level as far as updating from "mysql_query('delete from tbl_volte7');" to $query_1=mysqli_query($con, $delete_query)
$query_1 = mysqli_query($con, $delete_query);
//this is me just making sure I had a connection and I was actually interacting with my database
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 ***/
$file->preserveWhiteSpace = false;
/*** the table by its tag name ***/
$tables = $file->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');
var_dump($cols);
$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>";
?>
I've got the html file that's referenced in the code attached.
volte-7day.html
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ray, I'm applying your wisdom and I'm at a point where I want your "eyes."
I went back and changed things so I'm now in line with your suggestion as far as $con->query('delete from tbl_volte7') etc., so that's done.
I've broken the code down to this:
What I get when I run that is the following:
Now I can suppress those errors by doing this:
The main changes being:
$file=new domDocument; //line 13
$dom=@$file->loadHTML($htm l); //line 16
But my concern is that I'm overlooking something because I just feel like since this is "working code," for me to have to introduce something so soon in the syntax coupled with the fact that I seem to be lacking an "object" when I get a little further down the line, I don't know. Does anything look sinister to you at this point?
$dom=@$file->loadHTML($htm l);
I went back and changed things so I'm now in line with your suggestion as far as $con->query('delete from tbl_volte7') etc., so that's done.
I've broken the code down to this:
date_default_timezone_set('America/Chicago');
#!/usr/bin/php
//error_reporting(0);
ini_set('max_execution_time', 1200);
require 'common.php';
echo 'STARTING PROCC VOLTE VOLTE 7 DAY TBL ' . date('h:i:s') . "<br>";
$html = file_get_contents('http://southareanetwork.nss.vzwnet.com/weekly_reports/uploads/volte_7day.html');
$con->query('delete from tbl_volte7');
/*** a new dom object ***/
$dom = new domDocument;
/*** load the html into the object ***/
$dom->loadHTML($html);
/*** 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');
if($rows)
{
echo "OK";
}
What I get when I run that is the following:
Warning: DOMDocument::loadHTML(): htmlParseStartTag: misplaced tag in Entity, line: 3 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseStartTag: misplaced tag in Entity, line: 4 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseStartTag: misplaced tag in Entity, line: 25 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 30 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 30 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 30 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 30 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 30 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 30 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 30 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 30 in /var/www/html/sasite/weekly_reports/procedures/procc_volte_7day.php on line 16 OK
Now I can suppress those errors by doing this:
<?php
date_default_timezone_set('America/Chicago');
#!/usr/bin/php
//error_reporting(0);
ini_set('max_execution_time', 1200);
require 'common.php';
echo 'STARTING PROCC VOLTE VOLTE 7 DAY TBL ' . date('h:i:s') . "<br>";
$html = file_get_contents('http://southareanetwork.nss.vzwnet.com/weekly_reports/uploads/volte_7day.html');
$con->query('delete from tbl_volte7');
/*** a new dom object ***/
$file = new domDocument;
/*** load the html into the object ***/
$dom=@$file->loadHTML($html);
/*** discard white space ***/
$file->preserveWhiteSpace = false;
/*** the table by its tag name ***/
$tables = $file->getElementsByTagName('table');
/*** get all rows from the table ***/
$rows = $tables->item(0)->getElementsByTagName('tr');
if($rows)
{
echo "OK";
}
?>
The main changes being:
$file=new domDocument; //line 13
$dom=@$file->loadHTML($htm
But my concern is that I'm overlooking something because I just feel like since this is "working code," for me to have to introduce something so soon in the syntax coupled with the fact that I seem to be lacking an "object" when I get a little further down the line, I don't know. Does anything look sinister to you at this point?
$dom=@$file->loadHTML($htm
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ray, I think I've found something:
When I run the first query, I get an error message that says:
Out of range value for column 'qci5_setup_attempts' at row 1
The datatype is int(11) and the actual value is 5237420333;
Even when I do this: "insert into tbl_volte7(qci5_setup_atte mpts) VALUES ('5237420333')" I get that error. Why am I getting that error?
When I run the first query, I get an error message that says:
Out of range value for column 'qci5_setup_attempts' at row 1
The datatype is int(11) and the actual value is 5237420333;
Even when I do this: "insert into tbl_volte7(qci5_setup_atte
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Changed datatype to BIGINT(15) and am getting the same error.
What am I missing?
What am I missing?
ASKER
Never mind. Hang on...
ASKER
Got it!
Thanks!
Thanks!
ASKER
If the first place where everything goes south is: $dom->preserveWhiteSpace and I've declared $dom as $dom=@$file->loadHTML, I'm thinking that at that point my "object" is $dom and you're saying that I've got keep using $file.
Not arguing, just trying to figure out how to correctly apply your suggestion.
How would the corrected lines look (specifically #33 [$dom->preserveWhiteSpace=