tags:

views:

26

answers:

1

hello there. - just can't seem to get a result from a function called in its class...

require_once($_SERVER['DOCUMENT_ROOT']."/youradmin_v2/scripts/php/IPTC.php"); 

class Media{

    function Media() {
        // connects to db
    }

    function getMetaData($mediaID){
        global $select;

        $mediaDB = $select->mediaSelect($mediaID);
        $filePath=$mediaDB['filePath'];

        $itpc =new Image_IPTC($filePath);
        return $itpc->getTag($tag,0)." called?";
    }


function newFileProcessing($file_name){
     global $func;  
    global $select, $insert, $update;   

    $mediaID=$insert->addMedia($file_name, $filetype, $filePathImg,$testI);

    $mediaDB = $select->mediaSelect($mediaID);
    $filePath=$_SERVER['DOCUMENT_ROOT'].$mediaDB['pathToFile'];

    $update->updateQuery('media',"title='".$this->getMetaData($mediaID)."'");   
}

}
 $media = new Media; 

when i use $media->getMetaData($mediaID) on a php page it works? No errors and when its called in the class " called?" is added to the entry so i think its somink to do with the $itpc =new Image_IPTC($filePath) part which can be viewed here;

iptc class

can anyone see what i'm doing wrong?! any pointers appreciated.

best, dan.

A: 
$this->getMetaData($mediaID)

is not going to work in the function newFileProcessing($file_name) because it is not a member function of the Media class

if your code looked like this it should work

require_once($_SERVER['DOCUMENT_ROOT']."/youradmin_v2/scripts/php/IPTC.php"); 

class Media{

    function Media() {
        // connects to db
    }

    function getMetaData($mediaID){
        global $select;

        $mediaDB = $select->mediaSelect($mediaID);
        $filePath=$mediaDB['filePath'];

        $itpc =new Image_IPTC($filePath);
        return $itpc->getTag($tag,0)." called?";
    }


    function newFileProcessing($file_name){
      global $func;   
      global $select, $insert, $update;   

      $mediaID=$insert->addMedia($file_name, $filetype, $filePathImg,$testI);

      $mediaDB = $select->mediaSelect($mediaID);
      $filePath=$_SERVER['DOCUMENT_ROOT'].$mediaDB['pathToFile'];

      $update->updateQuery('media',"title='".$this->getMetaData($mediaID)."'");   
   }
}

$media = new Media;
Tristan
thanks for getting back tristan. Not sure if i've been staring too hard but i can't see anything different in your code? best, Dan.
daniel Crabbe
how would i make newFileProcessing a member function of the Media class and what are the implications for it being called out of the class? cheers...
daniel Crabbe
the difference in code is that newFileProccessing is within the scope of the Media Class (look at the beginning and end of the braces between yours and mine) and their won't be any implications you should be able to call newFileProcessing like $media->newFileProcessing(fileName)
Tristan
ah - crap - that's a typo and it is actually in the class.
daniel Crabbe
I can't actually access that IPTC script you posted could that be what you experiencing?
Tristan
no - the script works. Another typo - http://oursite.modernactivity.co.uk/IPTC.txt
daniel Crabbe