2012-04-03 98 views
0

爲什麼我在代碼中收到以下錯誤?致命錯誤:無法在寫入上下文中使用函數返回值

Fatal error: Can't use function return value in write context in....

我我不得不返回內聲明的,如果...否則當我第一次開始對這個功能的工作,並且錯誤似乎是一個具有return語句做。但我用echo聲明替換了它們,而且我仍然收到錯誤,所以我不知道發生了什麼。任何幫助或建議?

public function wallPostComments() { 
    // This function processes wall post comments 
    // pull the submitted comment data 
    $returnedPostId = $this->inuput->post('entryId'); 
    $returnedCommentData = $this->input->post('returnedCommentData'); 

    // pull the required session data 
    $userid = $this->session->userdata('userid'); 

    // select the sql data from wallPosts and wallPostComments 
    $query = $this->db->query("SELECT * FROM wallPosts, wallPostComments"); 

    // loop through the mysql rows and process the expanded sql code 
    foreach ($query->result() as row()) { 
     if($row->idwallPosts == $JSONedIdWallPosts) { 
      echo "success"; 
     } else { 
      echo "failure"; 
     } 
    } 
} 
+0

你如何使用'wallPostComments()'?顯示該代碼。 $ JSONedIdWallPosts定義在哪裏? – 2012-04-03 00:45:32

回答

3

row()什麼時候變成了函數?

嘗試:

foreach ($query->result() as $row) { 
+0

哦哇大聲笑..我覺得愚蠢。接得好。謝啦! – 2012-04-03 00:50:58

+0

啊,每個人都有這些日子,不要覺得不好。 – 2012-04-03 01:11:07

相關問題