开发者

cant call function from within its class but can otherwise?

开发者 https://www.devze.com 2023-01-14 20:16 出处:网络
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\");
  • 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-开发者_JAVA百科>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.


$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;
0

精彩评论

暂无评论...
验证码 换一张
取 消