class problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stijn Goris

    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($i ndex);

    include_once('c lass.UploadPict ure.php');
    class Album
    {
    var $objImage;

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

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


  • -Ema-

    #2
    Re: class problem

    Stijn Goris wrote:
    [color=blue]
    > 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?
    >[/color]
    Try to print out the $objImage.
    The problem is probably on the:
    *$objImage = new UploadPicture($ width,'');*[color=blue]
    >
    >
    > The errorline is: $objImage->createImage($i ndex);
    >
    > include_once('c lass.UploadPict ure.php');
    > class Album
    > {
    > var $objImage;
    >
    > function Album($width) //constructor
    > {
    > $objImage = new UploadPicture($ width,'');[/color]
    if( !$objImage )
    echo 'objImage is null!';[color=blue]
    > }
    >
    > function putImage($index )
    > {
    > $objImage->createImage($i ndex);
    > }
    > }
    > ?>
    >
    >[/color]

    -Ema-

    Comment

    • Stijn Goris

      #3
      Re: class problem


      "-Ema-" <a@b.c> wrote in message
      news:a2vRb.2901 17$e6.11243424@ twister2.libero .it...[color=blue]
      > Stijn Goris wrote:
      >[color=green]
      > > 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?
      > >[/color]
      > Try to print out the $objImage.
      > The problem is probably on the:
      > *$objImage = new UploadPicture($ width,'');*[color=green]
      > >
      > >
      > > The errorline is: $objImage->createImage($i ndex);
      > >
      > > include_once('c lass.UploadPict ure.php');
      > > class Album
      > > {
      > > var $objImage;
      > >
      > > function Album($width) //constructor
      > > {
      > > $objImage = new UploadPicture($ width,'');[/color]
      > if( !$objImage )
      > echo 'objImage is null!';[color=green]
      > > }
      > >
      > > function putImage($index )
      > > {
      > > $objImage->createImage($i ndex);
      > > }
      > > }
      > > ?>
      > >
      > >[/color]
      >
      > -Ema-
      >[/color]

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

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

      It works

      but when I do

      function Album($width) //constructor
      {
      $this->setCurrentPeri od();
      $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





      Comment

      • -Ema-

        #4
        Re: class problem

        Stijn Goris wrote:
        [color=blue]
        > "-Ema-" <a@b.c> wrote in message
        > news:a2vRb.2901 17$e6.11243424@ twister2.libero .it...
        >[color=green]
        >>Stijn Goris wrote:
        >>
        >>[color=darkred]
        >>>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?
        >>>[/color]
        >>
        >>Try to print out the $objImage.
        >>The problem is probably on the:
        >>*$objImage = new UploadPicture($ width,'');*
        >>[color=darkred]
        >>>
        >>>The errorline is: $objImage->createImage($i ndex);
        >>>
        >>>include_once ('class.UploadP icture.php');
        >>>class Album
        >>>{
        >>> var $objImage;
        >>>
        >>> function Album($width) //constructor
        >>> {
        >>> $objImage = new UploadPicture($ width,'');[/color]
        >>
        >> if( !$objImage )
        >>echo 'objImage is null!';
        >>[color=darkred]
        >>> }
        >>>
        >>> function putImage($index )
        >>> {
        >>> $objImage->createImage($i ndex);
        >>> }
        >>>}
        >>>?>
        >>>
        >>>[/color]
        >>-Ema-
        >>[/color]
        >
        >
        > The object is created correctly but seems to be unknown in the putImage
        > function.
        > When I do
        >
        > function Album($width) //constructor
        > {
        > $this->setCurrentPeri od();
        > $objImage = new UploadPicture($ width,'');
        > $objImage->createImage(0) ;
        > }
        >
        > It works
        >
        > but when I do
        >
        > function Album($width) //constructor
        > {
        > $this->setCurrentPeri od();
        > $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
        >
        >
        >
        >
        >[/color]
        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($i ndex);
        }
        }

        see you.
        -Ema-

        Comment

        • Stijn Goris

          #5
          Re: class problem


          "-Ema-" <a@b.c> wrote in message
          news:rWvRb.2902 52$e6.11245969@ twister2.libero .it...[color=blue]
          > Stijn Goris wrote:
          >[color=green]
          > > "-Ema-" <a@b.c> wrote in message
          > > news:a2vRb.2901 17$e6.11243424@ twister2.libero .it...
          > >[color=darkred]
          > >>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($i ndex);
          > >>>
          > >>>include_once ('class.UploadP icture.php');
          > >>>class Album
          > >>>{
          > >>> var $objImage;
          > >>>
          > >>> function Album($width) //constructor
          > >>> {
          > >>> $objImage = new UploadPicture($ width,'');
          > >>
          > >> if( !$objImage )
          > >>echo 'objImage is null!';
          > >>
          > >>> }
          > >>>
          > >>> function putImage($index )
          > >>> {
          > >>> $objImage->createImage($i ndex);
          > >>> }
          > >>>}
          > >>>?>
          > >>>
          > >>>
          > >>-Ema-
          > >>[/color]
          > >
          > >
          > > The object is created correctly but seems to be unknown in the putImage
          > > function.
          > > When I do
          > >
          > > function Album($width) //constructor
          > > {
          > > $this->setCurrentPeri od();
          > > $objImage = new UploadPicture($ width,'');
          > > $objImage->createImage(0) ;
          > > }
          > >
          > > It works
          > >
          > > but when I do
          > >
          > > function Album($width) //constructor
          > > {
          > > $this->setCurrentPeri od();
          > > $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
          > >
          > >
          > >
          > >
          > >[/color]
          > 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($i ndex);
          > }
          > }
          >
          > see you.
          > -Ema-
          >[/color]

          thanks, I should hhave seen it


          Comment

          Working...