2012-03-19 14 views
0

致命錯誤:無法在/ home/dokito/public_html/dokito/lib/class_twitter中重新聲明check_twitter_search_db()(以前在/home/dokito/public_html/dokito/lib/class_twitter.php:261中聲明)。 php on line 012php類拋出了redeclreation的錯誤。聲明只能執行一次

而在有人問起之前,這個類只聲明瞭一次。

編輯:類只包含一次。

編輯的代碼

 

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

+4

您必須多次包括它們 - 嘗試使用'require_once'來代替。 – 2012-03-19 12:32:07

+0

@EvanMulawski應該(或已經)回答:)。 – AD7six 2012-03-19 12:33:13

回答

2

你包括文件的兩倍。嘗試將include()require()調用更改爲include_once()require_once()

+0

恢復與舊版本工作的文件。問題本身就是班級。仍然無法弄清楚什麼是錯的:) – gauravtechie 2012-03-19 13:55:38

相關問題