class problem

This is a discussion on class problem within the PHP Language forums, part of the PHP Programming Forums category; I get an error: Fatal error: Call to a member function on a non-object in It s telling me ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-27-2004
Stijn Goris
 
Posts: n/a
Default class problem

I get an error:
Fatal error: Call to a member function on a non-object in

It s telling me that $objImage: is not an object. Although i made it an
object in the constructor. Someone can help me out?

kind regards
Stijn


The errorline is: $objImage->createImage($index);

include_once('class.UploadPicture.php');
class Album
{
var $objImage;

function Album($width) //constructor
{
$objImage = new UploadPicture($width,'');
}

function putImage($index)
{
$objImage->createImage($index);
}
}
?>


Reply With Quote
  #2 (permalink)  
Old 01-27-2004
-Ema-
 
Posts: n/a
Default Re: class problem

Stijn Goris wrote:

> I get an error:
> Fatal error: Call to a member function on a non-object in
>
> It s telling me that $objImage: is not an object. Although i made it an
> object in the constructor. Someone can help me out?
>

Try to print out the $objImage.
The problem is probably on the:
*$objImage = new UploadPicture($width,'');*
>
>
> The errorline is: $objImage->createImage($index);
>
> include_once('class.UploadPicture.php');
> class Album
> {
> var $objImage;
>
> function Album($width) //constructor
> {
> $objImage = new UploadPicture($width,'');

if( !$objImage )
echo 'objImage is null!';
> }
>
> function putImage($index)
> {
> $objImage->createImage($index);
> }
> }
> ?>
>
>


-Ema-

Reply With Quote
  #3 (permalink)  
Old 01-27-2004
Stijn Goris
 
Posts: n/a
Default Re: class problem


"-Ema-" <a@b.c> wrote in message
news:a2vRb.290117$e6.11243424@twister2.libero.it.. .
> Stijn Goris wrote:
>
> > I get an error:
> > Fatal error: Call to a member function on a non-object in
> >
> > It s telling me that $objImage: is not an object. Although i made it an
> > object in the constructor. Someone can help me out?
> >

> Try to print out the $objImage.
> The problem is probably on the:
> *$objImage = new UploadPicture($width,'');*
> >
> >
> > The errorline is: $objImage->createImage($index);
> >
> > include_once('class.UploadPicture.php');
> > class Album
> > {
> > var $objImage;
> >
> > function Album($width) //constructor
> > {
> > $objImage = new UploadPicture($width,'');

> if( !$objImage )
> echo 'objImage is null!';
> > }
> >
> > function putImage($index)
> > {
> > $objImage->createImage($index);
> > }
> > }
> > ?>
> >
> >

>
> -Ema-
>


The object is created correctly but seems to be unknown in the putImage
function.
When I do

function Album($width) //constructor
{
$this->setCurrentPeriod();
$objImage = new UploadPicture($width,'');
$objImage->createImage(0);
}

It works

but when I do

function Album($width) //constructor
{
$this->setCurrentPeriod();
$objImage = new UploadPicture($width,'');
$this->putImage(1);
}

function putImage($index)
{
$objImage->createImage(1);
}

I get the error: Fatal error: Call to a member function on a non-object

Someone knows what the problem is?
kind regards
Stijn





Reply With Quote
  #4 (permalink)  
Old 01-27-2004
-Ema-
 
Posts: n/a
Default Re: class problem

Stijn Goris wrote:

> "-Ema-" <a@b.c> wrote in message
> news:a2vRb.290117$e6.11243424@twister2.libero.it.. .
>
>>Stijn Goris wrote:
>>
>>
>>>I get an error:
>>>Fatal error: Call to a member function on a non-object in
>>>
>>>It s telling me that $objImage: is not an object. Although i made it an
>>>object in the constructor. Someone can help me out?
>>>

>>
>>Try to print out the $objImage.
>>The problem is probably on the:
>>*$objImage = new UploadPicture($width,'');*
>>
>>>
>>>The errorline is: $objImage->createImage($index);
>>>
>>>include_once('class.UploadPicture.php');
>>>class Album
>>>{
>>> var $objImage;
>>>
>>> function Album($width) //constructor
>>> {
>>> $objImage = new UploadPicture($width,'');

>>
>> if( !$objImage )
>>echo 'objImage is null!';
>>
>>> }
>>>
>>> function putImage($index)
>>> {
>>> $objImage->createImage($index);
>>> }
>>>}
>>>?>
>>>
>>>

>>-Ema-
>>

>
>
> The object is created correctly but seems to be unknown in the putImage
> function.
> When I do
>
> function Album($width) //constructor
> {
> $this->setCurrentPeriod();
> $objImage = new UploadPicture($width,'');
> $objImage->createImage(0);
> }
>
> It works
>
> but when I do
>
> function Album($width) //constructor
> {
> $this->setCurrentPeriod();
> $objImage = new UploadPicture($width,'');
> $this->putImage(1);
> }
>
> function putImage($index)
> {
> $objImage->createImage(1);
> }
>
> I get the error: Fatal error: Call to a member function on a non-object
>
> Someone knows what the problem is?
> kind regards
> Stijn
>
>
>
>
>

Yeah! I'm stupid! This is a tivial error. You must referentiate always
your member variables with $this. So your class is:
class Album
{
var $objImage;

function Album($width) //constructor
{
$this->objImage = new UploadPicture($width,'');
}

function putImage($index)
{
$this->objImage->createImage($index);
}
}

see you.
-Ema-

Reply With Quote
  #5 (permalink)  
Old 01-27-2004
Stijn Goris
 
Posts: n/a
Default Re: class problem


"-Ema-" <a@b.c> wrote in message
news:rWvRb.290252$e6.11245969@twister2.libero.it.. .
> Stijn Goris wrote:
>
> > "-Ema-" <a@b.c> wrote in message
> > news:a2vRb.290117$e6.11243424@twister2.libero.it.. .
> >
> >>Stijn Goris wrote:
> >>
> >>
> >>>I get an error:
> >>>Fatal error: Call to a member function on a non-object in
> >>>
> >>>It s telling me that $objImage: is not an object. Although i made it an
> >>>object in the constructor. Someone can help me out?
> >>>
> >>
> >>Try to print out the $objImage.
> >>The problem is probably on the:
> >>*$objImage = new UploadPicture($width,'');*
> >>
> >>>
> >>>The errorline is: $objImage->createImage($index);
> >>>
> >>>include_once('class.UploadPicture.php');
> >>>class Album
> >>>{
> >>> var $objImage;
> >>>
> >>> function Album($width) //constructor
> >>> {
> >>> $objImage = new UploadPicture($width,'');
> >>
> >> if( !$objImage )
> >>echo 'objImage is null!';
> >>
> >>> }
> >>>
> >>> function putImage($index)
> >>> {
> >>> $objImage->createImage($index);
> >>> }
> >>>}
> >>>?>
> >>>
> >>>
> >>-Ema-
> >>

> >
> >
> > The object is created correctly but seems to be unknown in the putImage
> > function.
> > When I do
> >
> > function Album($width) //constructor
> > {
> > $this->setCurrentPeriod();
> > $objImage = new UploadPicture($width,'');
> > $objImage->createImage(0);
> > }
> >
> > It works
> >
> > but when I do
> >
> > function Album($width) //constructor
> > {
> > $this->setCurrentPeriod();
> > $objImage = new UploadPicture($width,'');
> > $this->putImage(1);
> > }
> >
> > function putImage($index)
> > {
> > $objImage->createImage(1);
> > }
> >
> > I get the error: Fatal error: Call to a member function on a non-object
> >
> > Someone knows what the problem is?
> > kind regards
> > Stijn
> >
> >
> >
> >
> >

> Yeah! I'm stupid! This is a tivial error. You must referentiate always
> your member variables with $this. So your class is:
> class Album
> {
> var $objImage;
>
> function Album($width) //constructor
> {
> $this->objImage = new UploadPicture($width,'');
> }
>
> function putImage($index)
> {
> $this->objImage->createImage($index);
> }
> }
>
> see you.
> -Ema-
>


thanks, I should hhave seen it


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:21 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0