chrism2011 Posted February 18, 2011 Share Posted February 18, 2011 I get the error code "Fatal error: Using $this when not in object context in /home/feenetwo/public_html/language/english/mails/sale_third_party_notification.php on line 7" when I complete the form from the link in the screenshot atached... the site is feenetwork.com and im getting really fustrated with it.... Can anyone help? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/228090-fatal-error-using-this-when-not-in-object-context/ Share on other sites More sharing options...
chrism2011 Posted February 18, 2011 Author Share Posted February 18, 2011 sorry here is the file thats getting the error... <? ## Email File -> notify buyer on a successful purchase ## called only from the $item->assign_winner() function! if ( !defined('INCLUDED') ) { die("Access Denied"); } $sale_details = $this->get_sql_row("SELECT w.*, u.name, u.email a.name AS item_name, a.currency FROM " . DB_PREFIX . "winners w LEFT JOIN " . DB_PREFIX . "applications_details u ON u.application_id=w.application_id LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=w.auction_id WHERE w.winner_id='" . $mail_input_id . "'"); $send = true; ## text message - editable $text_message = 'Dear %1$s, You have successfully purchased %2$s. Purchase Details: - price: %3$s - quantity purchased: %4$s - auction url: %7$s For more details about the purchase, please access the "Won Items" page, by clicking on the link below: %5$s After you have accessed the page above, click on the "Message Board" link next to each item won. This message board is your direct communication board with the seller. Please use this board to ask any post sale questions you might have. Important: To help resolve any possible disputes ensure you use the board for all queries and updates. Best regards, The %6$s staff'; ## html message - editable $html_message = 'Dear %1$s, <br> <br> You have successfully purchased %2$s. <br> <br> Purchase Details: <br> <ul> <li>Price: <b>%3$s</b> </li> <li>Quantity Purchased: <b>%4$s</b> </li> <li>Auction URL: [ <a href="%7$s">Click to View</a> ] </li> </ul> For more details about the purchase, please access the [ <a href="%5$s">Won Items</a> ] page. <br> <br> After you have accessed the page above, click on the "Message Board" link next to each item won. <br> This message board is your direct communication board with the seller. Please use this board to ask any post sale questions you might have. <br> <br> Important: To help resolve any possible disputes ensure you use the board for all queries and updates. <br> <br> Best regards, <br> The %6$s staff'; $items_won_link = SITE_PATH . 'login.php?redirect=' . process_link('members_area', array('page' => 'bidding', 'section' => 'won_items')); $auction_link = process_link('auction_details', array('name' => $sale_details['item_name'], 'auction_id' => $sale_details['auction_id'])); $this->fees = new fees(); $this->fees->setts = $this->setts; $sale_price = $this->fees->display_amount($sale_details['bid_amount'], $sale_details['currency']); $text_message = sprintf($text_message, $sale_details['name'], $sale_details['item_name'], $sale_price, $sale_details['quantity_offered'], $items_won_link, $this->setts['sitename'], $auction_link); $html_message = sprintf($html_message, $sale_details['name'], $sale_details['item_name'], $sale_price, $sale_details['quantity_offered'], $items_won_link, $this->setts['sitename'], $auction_link); send_mail($sale_details['email'], 'Auction ID: ' . $sale_details['auction_id'] . ' - Successful Purchase', $text_message, $this->setts['admin_email'], $html_message, null, $send); ?> Quote Link to comment https://forums.phpfreaks.com/topic/228090-fatal-error-using-this-when-not-in-object-context/#findComment-1176189 Share on other sites More sharing options...
cyberRobot Posted February 18, 2011 Share Posted February 18, 2011 Looks like your using the variable "$this" where it's not allowed. If you need help fixing the code, could you post the code? Quote Link to comment https://forums.phpfreaks.com/topic/228090-fatal-error-using-this-when-not-in-object-context/#findComment-1176191 Share on other sites More sharing options...
chrism2011 Posted February 18, 2011 Author Share Posted February 18, 2011 I have posted above - i would love some help!! Been staring at it for way too long now Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/228090-fatal-error-using-this-when-not-in-object-context/#findComment-1176193 Share on other sites More sharing options...
KevinM1 Posted February 18, 2011 Share Posted February 18, 2011 $this is a PHP keyword which is only allowed to be used within a class. It seems as though your file is supposed to be part of an OO system, but something got mucked up somewhere so it's not actually a class. Quote Link to comment https://forums.phpfreaks.com/topic/228090-fatal-error-using-this-when-not-in-object-context/#findComment-1176195 Share on other sites More sharing options...
cyberRobot Posted February 18, 2011 Share Posted February 18, 2011 I think the issue starts here: <?php ... $this->fees = new fees(); $this->fees->setts = $this->setts; ... ?> When creating an instance of a class, it should be more like: <?php ... fees = new fees(); fees->setts = 'some value'; ... ?> It might be helpful to review the PHP manual section for classes: http://www.php.net/manual/en/language.oop5.basic.php Quote Link to comment https://forums.phpfreaks.com/topic/228090-fatal-error-using-this-when-not-in-object-context/#findComment-1176196 Share on other sites More sharing options...
KevinM1 Posted February 18, 2011 Share Posted February 18, 2011 The question is whether this file is included in another. What little context we can see leads me to believe so. Regardless, it's quite clearly a 3rd party script, and a bad one at that. Whoever wrote it clearly doesn't understand basic OO principles. Quote Link to comment https://forums.phpfreaks.com/topic/228090-fatal-error-using-this-when-not-in-object-context/#findComment-1176199 Share on other sites More sharing options...
chrism2011 Posted February 18, 2011 Author Share Posted February 18, 2011 Thanks for all your help... I think it was written by one of my past collegues but not quite sure... Its part of a site thats built on php probid. Ill keep cracking on with it, im sure i will come up with something. if anyone can shed some light on it please let me know. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/228090-fatal-error-using-this-when-not-in-object-context/#findComment-1176205 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.