/    Sign up×
Community /Pin to ProfileBookmark

Fatal error: Call to a member function postage_country_display() on a non-object

Hello guys ?

I’m pulling out my last remaining hairs with this PHP problem. I’m not really good at PHP but I’m trying to do some changes to a script as instructed by the developer, but apparently I got some wrong instructions. The error I get is:

[B]Fatal error: Call to a member function postage_country_display() on a non-object in file.php on line 34[/B]

I’ve been searching the web high and low and can’t seem to find a solution. Does anyone have a hint at what might be wrong?

?

Here is the code that’s causing the problem and the class.

Code:

[code=php]
$template->set(‘items_id’, intval($_REQUEST[‘items_id’]));

$item_details = $db->get_sql_row(“SELECT * FROM ” . DB_PREFIX . “items WHERE
items_id='” . intval($_REQUEST[‘items_id’]) . “‘”);

$unCountryPrice = unserialize(stripslashes($db->add_special_chars($item_details[‘country_postage’])));
// print_r($unCountryPrice);

$postageCountry = $item->postage_country_display($unCountryPrice,$item_details[‘currency’]);

$template->set(‘postageCountry’, $postageCountry);

$template->set(‘item_details’, $item_details);
[/code]

And here is the class:

[code=php]
function postage_country_display($unCountryPrice,$currency) {
if (is_array($unCountryPrice)) {

$postageCountry = “<table border=”0″ cellspacing=”0″ cellpadding=”0”>
“;
$fees = new fees();
while (list($k,$v)= each($unCountryPrice)){
$cQueyr = $this->query(“SELECT a.name as name1,b.name as name2 FROM ” . DB_PREFIX . “countries a LEFT JOIN ” . DB_PREFIX . “countries b ON (a.parent_id = b.id) WHERE a.id = ‘”. $k .”‘”);
$cRow = $this->fetch_array($cQueyr);

$postageCountry.=”<tr><td>”. ($cRow[‘name2’]==””?$cRow[‘name1’]:$cRow[‘name2′].’ > ‘.$cRow[‘name1′]) .”</td><td>&nbsp;”.$currency.’ ‘.number_format($v,2).”</td></tr>”;
}
$postageCountry.=”</table>”;
}
return $postageCountry;
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@shannontauthorMar 08.2012 — I forgot to mention, when I uncomment this line:

// print_r($unCountryPrice);

and comment the line below instead, then it outputs the script correctly and also the variables correctly on top of the HTML page like this:

Array ( [2084] => 1.00 [1903] => 2.00 )

Maybe that helps.
Copy linkTweet thisAlerts:
@shannontauthorMar 08.2012 — Got it working. I had to move the code under where $item is defined. CASE CLOSED!
×

Success!

Help @shannont spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...