php类抛出重新翻译的错误。宣言只进行一次

时间:2012-03-19 12:30:42

标签: php

致命错误:无法在第261行的/home/dokito/public_html/dokito/lib/class_twitter.php中重新声明check_twitter_search_db()(之前在/home/dokito/public_html/dokito/lib/class_twitter.php:261中声明)

在有人要求之前,该课程只宣布一次。

已编辑:课程仅包含一次。

使用代码编辑


    --- lib/class_twitter.php   (revision 8909)
    +++ lib/class_twitter.php   (revision 5168)
    @@ -12,7 +12,7 @@
     include_once "epitwitter/EpiCurl.php";
     include_once "epitwitter/EpiOAuth.php";
     include_once "epitwitter/EpiTwitter.php";
    -//include_once "class.logging.inc.php";
    +include_once "class.logging.inc.php";
     /*
     // register at http://twitter.com/oauth_clients and fill these two 
     define("TWITTER_CONSUMER_KEY", "Removed");
    @@ -209,13 +209,12 @@
             $user = '';
             $fn_name = 'twitter_search_save';
             $twitter_data = $this->twitter_search($keyword, $i, $geocode);
    -        //print_r($twitter_data);
    +        print_r($twitter_data);
             if($twitter_data != ''){
            echo "We found data for profile id $id, total tweets are" . count($twitter_data);
    -       if (count($twitter_data) > 1){
                 foreach($twitter_data as $d){
                     //print_r($d);
    -                //die;
    +                die;
                     $status_ID = $db->escape($d->id_str);

                     $published = $db->escape($d->created_at);
    @@ -224,7 +223,18 @@
                     $author_name = $db->escape($d->from_user);
                     $user_id = $d->from_user_id;
                     if(!$this->check_twitter_search_db($status_ID, $id)){
    -                     $q = "INSERT INTO `twitter_search` (`keyword`, `status_ID`, `published`, `unix_timestamp`, `text`, `author_name`, `profile_id`, `user_id`) VALUES ('$keyword', '$status_ID', '$published', '$unix_date', '$text', '$author_name', '$id', '$user_id')";            
    +                    
    +                    //$klout_score = $this->klout_score($author_name);
    +                    //$user = $this->get_user($author_name);
    +                    /**
    +                     * Right Now No check. It wastes the API call. better to save data and discard the unwanted. 
    +                     * This will speed up the process too.
    +                     * Check whether the USER is from INDIA
    +                     * 
    +                     */
    +                    //if($user['utc_offset'] == '19800'){
    +                        $q = "INSERT INTO `twitter_search` (`keyword`, `status_ID`, `published`, `unix_timestamp`, `text`, `author_name`, `profile_id`, `user_id`) VALUES ('$keyword', '$status_ID', '$published', '$unix_date', '$text', '$author_name', '$id', '$user_id')";
    +           
                            if($db->query($q)){
                            echo "Inserting tweet status $status_ID for profile $id";
                            echo "\n";
    @@ -243,7 +253,11 @@
                         //}                 
                     }                
                 }
    +           if(sizeof($user) > 0){
    +            $this->save_user_lookup($user);            
    +           }
             }
    +
        else{
            echo "No data found for profile_id $id";
        }     
    @@ -256,9 +270,8 @@
          * 
          * Check if STATUS is present in the DB with the same KEYWORD
          * 
    -*/
    - 
    -        function check_twitter_search_db($status_ID, $id){
    +     */
    +    function check_twitter_search_db($status_ID, $id){
             global $db;
             $q = "SELECT * FROM `twitter_search` WHERE `status_ID` = '$status_ID' AND `profile_id` = '$id'";
             //echo $q;
    @@ -270,7 +283,15 @@
                 return true;
             }
         }
    -
    +    function check_twitter_status_db($status_ID){
    +        global $db;
    +        $q = "SELECT * FROM `twitter_status` WHERE `status_ID` = '$status_ID'";
    +        if($db->get_row($q, ARRAY_A) != 0){
    +            return true;
    +        }else{
    +            return false;
    +        }
    +    }
         function save_status($status_ID){
             global $db;
             $fn_name = 'save_status';
    @@ -475,8 +496,7 @@
             }

         }
    -}
    -  public function check_utc_offset($user_ID) {
    +    public function check_utc_offset($user_ID) {
             global $db;
             $fn_name = "check_utc_offset";
             $data = array();

1 个答案:

答案 0 :(得分:2)

你要两次包含这个文件。尝试将include()require()来电更改为include_once()require_once()