Q:

PHP pass variables between functions - Call to a member function on a non-object

I'm trying to pass a variable from one function to another in the same class, the purpose is to use it in a query.
I tried them all, $this, var_dump, fetch_assoc, ecc
How can I pass the $result variable in the query of the function due() ?
<?php
class modUno
{     
    public static function Uno()
    {   
        $db = JFactory::getDBO();   
        $query = "SELECT id AS memTotal FROM #__users WHERE username = 'bruno';";

        $db->setQuery($query);
        $result = $db->query();
        return $result->fetch_object()->memTotal;
    }

    public static function due()
    {
        $result->due();

        $db = JFactory::getDBO();   
        $query = "SELECT avatar AS memTotal FROM #__comprofiler WHERE id = '$result';";

        $db->setQuery($query);
        $resulta = $db->query();
        return $resulta->fetch_object()->memTotal;
    }
}
?>

sorry I have not actually specified well, what I'm trying to do is a module joomla 3.2, therefore consists of three files the one above is the "helper.php" contains the helper class which is used to do retrieving the information, then there's the "mod_chat.php" that perform initialization routines, call helper routines to collect data, finally, there is "default.php" that will take the data from mod_chat.php and generate the HTML!
mod_chat
enter code here

<?php

defined( '_JEXEC' ) or die( 'Restricted access' );
require_once( dirname(__FILE__).'/helper.php' );

$risultato = modUno::uno();
$foto = modUno::due();
require JModuleHelper::getLayoutPath('mod_chat');
?>

default.php
enter code here

<?php defined( '_JEXEC' ) or die( 'Restricted access' ); ?>

<p> risultato: <?php echo $risultato; ?></p>
<p> foto:<img src="http://somesite.com/images/comprofiler/<?php echo $foto; ?>" /></p>

I thank you all the rapid responses, I tried to make the changes that you suggested but keeps giving me error, now I will answer one by one on reported errors 
thanks again you are a great comunity

A:

When you want to share a variable among different methods of your class (without passing the variable as a parameter to each method), then the simplest way is to declare the variable as a class member.
E.g. 
class myClass {
   private $classVar;

   function someMethod() {
     $this->classVar = "something";
   }

   function anotherMethod() {
     echo $this->classVar;
   }
}

