Re: Strange non-object
| From: | Benjamin Smith | Date: | Wed, 07 Sep 2005 22:25:33 +0000 |
| Subject: | Re: Strange non-object | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6200@lists.php.net to get a copy of this message | ||
Try this:
function Inicializa(&$login)
{
$login->janela->hide();
include("main.php");
}
OR
function Inicializa()
{
global $login;
$login->janela->hide();
include("main.php");
}
$login, being defined OUTSIDE the function, is undefined INSIDE the function.
Somehow, you need to bring it into the local scope. For more information,
read what excellent online PHP manual says about variable scope:
http://us2.php.net/global
-Ben
On Wednesday 07 September 2005 10:29, Marcus Leandro de Faria Reis wrote:
> look at the code below:
>
> <?
> dl('php_gtk.' . PHP_SHLIB_SUFFIX);
>
> //inclui classes necessarias
> include_once '../classes/Login.class';
>
> $login = &new Login();
>
> $login->tabela_de_consulta = 'usuarios';
> $login->coluna_usuario = 'usuario_login';
> $login->coluna_senha = 'usuario_senha';
>
> $login->executar->connect_object('clicked', 'Inicializa');
>
> function Inicializa()
> {
> $login->janela->hide();
> include("main.php");
> }
>
>
>
> gtk::main();
>
>
>
>
> php says:
>
> Fatal error: Call to a member function on a non-object
> in /home/marcus/lanhelp/projetos/lanhelpsystem/gtk/lanhelpsystem.php on
> line 17 --> $login->janela->hide();
>
> $janela is a GtkWindow created inside Login.class with this line:
>
> $this->janela = &new GtkWindow;
>
> so, whats wrong??
>
>
> -----------------------------------
> Marcus Reis
> marcus@lanhelp.com.br
>
> Lanhelp Soluções
> www.lanhelp.com.br
>
>
>
>
>
> _______________________________________________________
> Yahoo! Messenger com voz: PROMOÇÃO VOCÊ PODE LEVAR UMA VIAGEM NA CONVERSA.
Participe! www.yahoo.com.br/messenger/promocao
>
> --
> PHP-GTK General Mailing List (http://gtk.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
"I kept looking around for somebody to solve the problem.
Then I realized I am somebody"
-Anonymous