Re: function misfunction

From: Date: Mon, 30 Dec 2002 16:23:03 +0000
Subject: Re: function misfunction
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-129681@lists.php.net to get a copy of this message
Besides what Michael and jason said, you seem not have the $tracking initialized (it is not an object). You need to call $tracking=new tracking(); somewhere in your code. Martin S wrote:
I'm trying to redo a db lookup into a function. The function is placed in a class called tracking and declared thus: function setCurrentDevGroup($devID)
       {
// start original routine
               $query = "SELECT dev_group FROM tracking WHERE (computer =                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           $devID)";
               $sth = $adb->prepare($query);
               if($sth)
               {
                       $res = $sth->execute();
                       $resulttable = $sth->fetchrow_hash();
                       $lookuptable = $resulttable["dev_group"];
                       return($lookuptable);
               }
//end original routine
       }
This is called from the code as: $tracking->setCurrentDevGroup($this->ComputerID); // $this->ComputerID is
                                                 // known as eg 5.
In the page which relies on the value of setCurrentDevGroup I get: Call to a member function on a non-object in /www/htdocs/dev/include/irm.inc on line 2857 Line 2857 is the one starting "$tracking->" above. Obviously I'm doing something wrong here. What? Cheers, Martin S.


« previous php.general (#129681) next »