Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Fatal error: Call to a member function on a non-object
Old 07-03-2005, 02:28 PM Fatal error: Call to a member function on a non-object
Junior Talker

Posts: 2
Trades: 0
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.
dadkins20 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-03-2005, 06:09 PM
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
You want to place the returned value of getTagContent() into a var, then construct your array using that var, not the function call i.e. $tag = getTagContent(); $total_due[$x]->$tag;
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 07-03-2005, 06:33 PM
Junior Talker

Posts: 2
Trades: 0
Actually, I figured out the problem. Later on in the code I overwrote the total_due variable, which contained the array. That's why it worked the first loop through and failed on the second attempt.

Moral of the story: Use better variable names.
dadkins20 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Fatal error: Call to a member function on a non-object
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.23782 seconds with 12 queries