Hello,
I'm having some trouble with this php script that I'm writing. It's a very odd error I haven't been able to find an answer for anywhere I'm getting the following error:
Fatal error: Call to a member function on a non-object in /homepages/2/d112938229/htdocs/dp/monthly_bill.php on line 68
Here's the related code for this line and error:
PHP Code:
$customer_refid = $xmlResponse->getBranches("report_basiccostsmonth/bill","refid");
$total_due = $xmlResponse->getBranches("report_basiccostsmonth/bill","totalexvat");
//loop through all of the records and update the totals accordingly
for ($x=0; $x < count($customer_refid); $x++) {
$temp_x = $x;
$temp_refid = $customer_refid[$temp_x]->getTagContent();
$temp_total_due = $total_due[$temp_x]->getTagContent(); //this is line 68
This script takes an XML document and parses through each record. Here's the weird part of this error. It works on the first loop through the XML document but fails on the second. Here is the important section of the XML document:
<bill>
<refid>31155152160</refid>
<totalexvat>0</totalexvat>
</bill>
<bill>
<refid>31202068052</refid>
<totalexvat>993</totalexvat>
</bill>
I've tried to narrow the error down and I can tell you this:
This works and displays 993
PHP Code:
$temp_x=1
echo($total_due[$temp_x]->getTagContent();
This works and displays 993
PHP Code:
$temp_x=1
echo($total_due[1]->getTagContent();
This works and displays 993
PHP Code:
$x=1
echo($total_due[$x]->getTagContent();
If put inside the for loop, this does not work.
PHP Code:
echo($total_due[$x]->getTagContent();
Am I missing something obvious here? Any help would be appreciated.