简体   繁体   English

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

[英]php class is throwing error of redeclreation. Declaration is done only once

Fatal error: Cannot redeclare check_twitter_search_db() (previously declared in /home/dokito/public_html/dokito/lib/class_twitter.php:261) in /home/dokito/public_html/dokito/lib/class_twitter.php on line 261 致命错误:无法在第261行的/home/dokito/public_html/dokito/lib/class_twitter.php中重新声明check_twitter_search_db()(之前在/home/dokito/public_html/dokito/lib/class_twitter.php:261中声明)

And before somebody asks, the class is declared only once. 在有人要求之前,该课程只宣布一次。

Edited: Class is included only once. 编辑:班级只包括一次。

Edited with code 用代码编辑

--- 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();

You're including the file twice. 你要两次包含这个文件。 Try changing the include() or require() calls to include_once() or require_once() 尝试将include()require()调用更改为include_once()require_once()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM