PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 24th, 2003, 12:29 PM
jben.net jben.net is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 51 jben.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 41 sec
Reputation Power: 12
Send a message via AIM to jben.net
PHP Fatal error: Call to a member function on a non-object

Hi,

If I've got a class with a method that uses PEAR's Mail class, why wouldn't this work ???
PHP Code:
// mail_test.php

require_once("Mail.php");

class 
users // open the class definition

 /**
        * PEAR mail object
        *
        * @var object
        * @access private
        */
        
var $_oMail;
        
        
// CONSTRUCTOR ::::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::

        /**
        * class constructor
        *
        * @param integer user id [optional]
        * @access public
        */
        
function users(') {

                // implement pear mail object
                $this->_oMail =& Mail::factory("mail");

                if (PEAR::isError($this->_oMail)) {

                        catchExc($this->_oMail->getMessage());
                }

        }

        **
        * send email notification
        *
        * @param string $sBody email body
        * @return boolean
        * @access private
        */
        function _notifyUser($sBody) {

                // assign mail properties
                $aUser = $this->getUser();
                $aHeaders["To"] = $sRecipients = $aUser["Email"];
                $aHeaders["From"] = ENTITY." Admin <".EMAIL.">";
                $aHeaders["Subject"] = ENTITY." System Account Notification";
                $aHeaders["Priority"] = "3";

                // try to send mail
                if (PEAR::isError($mailTmp = $this->_oMail->send($sRecipients, $aHeaders, $sBody))) {
                        catchExc($mailTmp->getMessage());
                return false;
                }
                
                return true;
        }

/** 
     * deactivate a user record
     *
     * @return boolean
     * @access public
     */
    function deactivateUser() {
        
        $sql = "UPDATE ".PREFIX."_admin_users SET 
                    status=0 
                WHERE 
                    admin_user_id=".$this->_iUserId;
        
        if (DB::isError($rsTmp = $this->_oConn->query($sql))) {
            
            catchExc($rsTmp->getMessage());
            return false;
        }
        
        // build user email
        $sBody = "Your ".ENTITY." account has been deactivated.";
        
        return $this->_notifyUser($sBody);
    }



The notifyUser method is called from within the deleteUser method (and others)

The code above has been stripped down, but I always get this error when anything tries to call the notifyUser() method:

PHP Fatal error: Call to a member function on a non-object in /Library/WebServer/Documents/mail_test.php

If I remove the actual line that sends the email, then everything works fine, but, obviously, the email never gets sent!

why doesn't $this->_oMail appear to be part of the class ???? Is that the problem ??

Thanks in advance,

Jon

Reply With Quote
  #2  
Old November 24th, 2003, 12:30 PM
jben.net jben.net is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 51 jben.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 41 sec
Reputation Power: 12
Send a message via AIM to jben.net
Also, I'm not getting any include errors, so I'm assuming that's not the problem. Also, the Mail class is instansiated in the users class constructor function, and I don't ever get any errors there.

weird init

Jon

Reply With Quote
  #3  
Old April 24th, 2010, 09:52 AM
sajjadnasiri sajjadnasiri is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 4 sajjadnasiri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 46 sec
Reputation Power: 0
fatal error

hello

I have installed Reverse Auction Factory component on my joomla website and when a user want to send new auction he/she encounter with this error:

Fatal error: Call to a member function get() on a non-object in /home/karanik/public_html/plugins/editors/xstandard.php on line 273

this is the code that has seia above:
----------------------------------------------------
function _displayButtons($name, $buttons)
{
// Load modal popup behavior
JHTML::_('behavior.modal', 'a.modal-button');

$args['name'] = $name;
$args['event'] = 'onGetInsertMethod';

$return = '';
$results[] = $this->update($args);
foreach ($results as $result) {
if (is_string($result) && trim($result)) {
$return .= $result;
}
}

if(!empty($buttons))
{
$results = $this->_subject->getButtons($name, $buttons);

/*
* This will allow plugins to attach buttons or change the behavior on the fly using AJAX
*/
$return .= "\n<div id=\"editor-xtd-buttons\">\n";
foreach ($results as $button)
{
/*
* Results should be an object
*/
if ( $button->get('name') )
{
$modal = ($button->get('modal')) ? 'class="modal-button"' : null;
$href = ($button->get('link')) ? 'href="'.$button->get('link').'"' : null;
$onclick = ($button->get('onclick')) ? 'onclick="'.$button->get('onclick').'"' : null;
$return .= "<div class=\"button2-left\"><div class=\"".$button->get('name')."\"><a ".$modal." title=\"".$button->get('text')."\" ".$href." ".$onclick." rel=\"".$button->get('options')."\">".$button->get('text')."</a></div></div>\n";
}
}
$return .= "</div>\n";
}

return $return;
}
}
-----------------------------------------------------------

the blue line is the code that has problem, how can I solve it?

Reply With Quote
  #4  
Old April 24th, 2010, 10:34 AM
mecanicu mecanicu is offline
anonymous
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 244 mecanicu User rank is Private First Class (20 - 50 Reputation Level)mecanicu User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 12 h 19 m 50 sec
Reputation Power: 8
It's hard to say when the function getButtons from the line:
$results = $this->_subject->getButtons($name, $buttons);
is not in your code
I assume you need to
foreach ($buttons as $button)
and delete the extra "}" sign

hope it helps

and please open your own threads, is easier to reach at yor problem

Last edited by mecanicu : April 24th, 2010 at 10:37 AM. Reason: ouch

Reply With Quote
  #5  
Old April 24th, 2010, 11:10 AM
sajjadnasiri sajjadnasiri is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 4 sajjadnasiri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 46 sec
Reputation Power: 0
Thanks and just a question

Thanks for your tip

I am not familiar with PHP coding

So, where mus I put the foreach ($buttons as $button) in the code?

Reply With Quote
  #6  
Old April 24th, 2010, 11:50 AM
sajjadnasiri sajjadnasiri is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 4 sajjadnasiri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 46 sec
Reputation Power: 0
a little more problem

about 80% of problem solved but it is an error in the middle of the form that is as follow:

Warning: Invalid argument supplied for foreach() in /home/karanik/public_html/plugins/editors/xstandard.php on line 262


So, what must I do to solve it?

Reply With Quote
  #7  
Old April 24th, 2010, 01:40 PM
mecanicu mecanicu is offline
anonymous
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 244 mecanicu User rank is Private First Class (20 - 50 Reputation Level)mecanicu User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 12 h 19 m 50 sec
Reputation Power: 8
Quote:
Originally Posted by sajjadnasiri
hello

I have installed Reverse Auction Factory component on my joomla website and when a user want to send new auction he/she encounter with this error:

Fatal error: Call to a member function get() on a non-object in /home/karanik/public_html/plugins/editors/xstandard.php on line 273

this is the code that has seia above:
----------------------------------------------------
function _displayButtons($name, $buttons)
{
// Load modal popup behavior
JHTML::_('behavior.modal', 'a.modal-button');

$args['name'] = $name;
$args['event'] = 'onGetInsertMethod';

$return = '';
$results[] = $this->update($args);
foreach ($results as $result) {
if (is_string($result) && trim($result)) {
$return .= $result;
}
}

if(!empty($buttons))
{
$results = $this->_subject->getButtons($name, $buttons);

/*
* This will allow plugins to attach buttons or change the behavior on the fly using AJAX
*/
$return .= "\n<div id=\"editor-xtd-buttons\">\n";
foreach ($results as $button)// this line seems to be wrong
{
/*
* Results should be an object
*/
if ( $button->get('name') )
{
$modal = ($button->get('modal')) ? 'class="modal-button"' : null;
$href = ($button->get('link')) ? 'href="'.$button->get('link').'"' : null;
$onclick = ($button->get('onclick')) ? 'onclick="'.$button->get('onclick').'"' : null;
$return .= "<div class=\"button2-left\"><div class=\"".$button->get('name')."\"><a ".$modal." title=\"".$button->get('text')."\" ".$href." ".$onclick." rel=\"".$button->get('options')."\">".$button->get('text')."</a></div></div>\n";
}
}
$return .= "</div>\n";
}

return $return;
}
}
-----------------------------------------------------------

the blue line is the code that has problem, how can I solve it?

I have pointed out (in red) the line that I think must be replaced with
foreach ($buttons as $button)

But for more accuracy I will need to see the code for _subject object

all the best

Reply With Quote
  #8  
Old April 24th, 2010, 01:51 PM
sajjadnasiri sajjadnasiri is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 4 sajjadnasiri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 46 sec
Reputation Power: 0
some problems

I have changed the code you have said but there is another problem yet:

Warning: Invalid argument supplied for foreach() in /home/karanik/public_html/plugins/editors/xstandard.php on line 275

total code of page as as followe:
---------------------------------------------------------
<?php
/**
* @version $Id: xstandard.php 10709 2008-08-21 09:58:52Z eddieajau $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Do not allow direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

/**
* XStandard Lite for Joomla! WYSIWYG Editor Plugin
*
* @package Editors
* @since 1.5
*/
class plgEditorXstandard extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
function plgEditorXstandard(& $subject, $config)
{
parent::__construct($subject, $config);
}

/**
* Method to handle the onInitEditor event.
* - Initializes the XStandard Lite WYSIWYG Editor
*
* @access public
* @return string JavaScript Initialization string
* @since 1.5
*/
function onInit()
{
$html = '';
ob_start();
?>
<script type="text/javascript" src="<?php echo JURI::root() ?>/plugins/editors/xstandard/xstandard.js"></script>
<?php
$html = ob_get_contents();
ob_end_clean();

return $html;
}

/**
* XStandard Lite WYSIWYG Editor - get the editor content
*
* @param string The name of the editor
*/
function onGetContent( $editor ) {
return "$('xstandard').value;";
}

/**
* XStandard Lite WYSIWYG Editor - set the editor content
*
* @param string The name of the editor
*/
function onSetContent( $editor, $html ) {
return "$('xstandard').value =". $html .";";
}

/**
* XStandard Lite WYSIWYG Editor - copy editor content to form field
*
* @param string The name of the editor
*/
function onSave( $editor ) {

$js = "var editor = $('xstandard');\n";
$js .= "editor.EscapeUnicode = true;";
$js .= "$('".$editor."').value = editor.value;";

return $js;
}

/**
* XStandard Lite WYSIWYG Editor - display the editor
*
* @param string The name of the editor area
* @param string The content of the field
* @param string The name of the form field
* @param string The width of the editor area
* @param string The height of the editor area
* @param int The number of columns for the editor area
* @param int The number of rows for the editor area
* @param mixed Can be boolean or array.
*/
function onDisplay( $name, $content, $width, $height, $col, $row, $buttons = true )
{
// Load modal popup behavior
JHTML::_('behavior.modal', 'a.modal-button');

// Only add "px" to width and height if they are not given as a percentage
if (is_numeric( $width )) {
$width .= 'px';
}
if (is_numeric( $height )) {
$height .= 'px';
}

jimport('joomla.environment.browser');
$instance =& JBrowser::getInstance();
$language =& JFactory::getLanguage();
$db =& JFactory::getDBO();

$url = JURI::root();

$lang = substr( $language->getTag(), 0, strpos( $language->getTag(), '-' ) );

if ($language->isRTL()) {
$direction = 'rtl';
} else {
$direction = 'ltr';
}

/*
* Lets get the default template for the site application
*/
$query = 'SELECT template'
. ' FROM #__templates_menu'
. ' WHERE client_id = 0'
. ' AND menuid = 0'
;
$db->setQuery( $query );
$template = $db->loadResult();

$file_path = JPATH_SITE .'/templates/'. $template .'/css/';
if ( !file_exists( $file_path .DS. 'editor.css' ) ) {
$template = 'system';
}

$css = JURI::root() .'/templates/'. $template . '/css/editor.css';

$html = '';
ob_start();
?>

<div style="border: 1px solid #D5D5D5">
<object type="application/x-xstandard" id="xstandard" class="<?php echo $name ?>" width="<?php echo $width ?>" height="<?php echo $height ?>">
<param name="Value" value="<?php echo $content ?>" />

<param name="Lang" value="<?php echo $lang ?>" />
<param name="Dir" value="<?php echo $direction ?>" />
<param name="EditorCSS" value="<?php echo $css ?>" />
<param name="EnablePasteMarkup" value="yes" />
<param name="EnableTimestamp" value="no" />
<param name="EscapeUnicode" value="no" />
<param name="ToolbarWysiwyg" value="line, hyperlink, attachment, directory, undo, , wysiwyg, source, screen-reader, ,expand; strong, em, underline, strikethrough, , align-left, align-center, align-right, , blockquote, undo-blockquote, ,numbering, bullets, , undo, redo, ,layout-table, data-table, draw-layout-table, draw-data-table" />
<param name="ToolbarSource" value="indent, whitespace, word-wrap, dim-tags, validate,, wysiwyg, source, screen-reader, , expand" />
<param name="ToolbarPreview" value="wysiwyg, source, screen-reader, ,expand" />
<param name="ToolbarScreenReader" value="wysiwyg, source, screen-reader, , expand" />
<param name="BackgroundColor" value="#F9F9F9" />
<param name="Mode" value="<?php echo $this->params->get('mode', 'wysiwyg'); ?>" />
<param name="IndentOutput" value="yes" />
<param name="Options" value="<?php echo $this->params->get('wrap', '0'); ?>" />
<param name="BorderColor" value="#FFF" />
<param name="Base" value="<?php echo $url ?>" />
<param name="ExpandWidth" value="800" />
<param name="ExpandHeight" value="600" />

<param name="LatestVersion" value="2.0.0.0" />

<param name="CMSCode" value="065126D6-357D-46FC-AF74-A1F5B2D5036E" />
<param name="CMSImageLibraryURL" value="<?php echo $url ?>plugins/editors/xstandard/imagelibrary.php" />
<param name="CMSAttachmentLibraryURL" value="<?php echo $url ?>plugins/editors/xstandard/attachmentlibrary.php" />
<param name="CMSDirectoryURL" value="<?php echo $url ?>plugins/editors/xstandard/directory.php" />
<param name="PreviewXSLT" value="<?php echo $url ?>plugins/editors/xstandard/preview.xsl" />

<param name="CSS" value="<?php echo $this->_getTemplateCss(); ?>" />

<textarea name="alternate1" id="alternate1" cols="60" rows="15"><?php echo $content ?></textarea>
</object>
<input type="hidden" id="<?php echo $name ?>" name="<?php echo $name ?>" value="" />
</div>
<?php
$html = ob_get_contents();
ob_end_clean();

$html .= $this->_displayButtons($name, $buttons);

return $html;
}

function onGetInsertMethod($name)
{
$doc = & JFactory::getDocument();

$js= "function jInsertEditorText( text ) {
var editor = document.getElementById('xstandard');
editor.InsertXML(text);
}";
$doc->addScriptDeclaration($js);

return true;
}

function _getTemplateCss()
{
$db =& JFactory::getDBO();

/*
* Lets get the default template for the site application
*/
$query = 'SELECT template'
. ' FROM #__templates_menu'
. ' WHERE client_id = 0'
. ' AND menuid = 0'
;
$db->setQuery( $query );
$template = $db->loadResult();

$content_css = JURI::root() .'/templates/'. $template .'/css/';

$file_path = JPATH_SITE .'/templates/'. $template .'/css/';
if ( file_exists( $file_path .DS. 'editor.css' ) ) {
$content_css = $content_css . 'editor.css' .'", ';
} else {
$content_css = $content_css . 'template_css.css", ';
}

return $content_css;
}

function _displayButtons($name, $buttons)

{
// Load modal popup behavior
JHTML::_('behavior.modal', 'a.modal-button');

$args['name'] = $name;
$args['event'] = 'onGetInsertMethod';

$return = '';
$results[] = $this->update($args);
foreach ($results as $result)
{
if (is_string($result) && trim($result))
{
$return .= $result;
}
}





if(!empty($buttons))
{
$results = $this->_subject->getButtons($name, $buttons);

/*
* This will allow plugins to attach buttons or change the behavior on the fly using AJAX
*/
$return .= "\n<div id=\"editor-xtd-buttons\">\n";
foreach ($buttons as $button)
{
/*
* Results should be an object
*/


if ( $button->get('name') )
{
$modal = ($button->get('modal')) ? 'class="modal-button"' : null;
$href = ($button->get('link')) ? 'href="'.$button->get('link').'"' : null;
$onclick = ($button->get('onclick')) ? 'onclick="'.$button->get('onclick').'"' : null;
$return .= "<div class=\"button2-left\"><div class=\"".$button->get('name')."\"><a ".$modal." title=\"".$button->get('text')."\" ".$href." ".$onclick." rel=\"".$button->get('options')."\">".$button->get('text')."</a></div></div>\n";
}

}
$return .= "</div>\n";
}


return $return;
}

}

Reply With Quote
  #9  
Old April 24th, 2010, 03:03 PM
mecanicu mecanicu is offline
anonymous
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 244 mecanicu User rank is Private First Class (20 - 50 Reputation Level)mecanicu User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 12 h 19 m 50 sec
Reputation Power: 8
Well, now I know.
This is JOOMLA. For this very big app there is a specialized forum. You can findi it here

all the best

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP Fatal error: Call to a member function on a non-object


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap