致命错误:无法在写入上下文中使用函数返回值

时间:2012-04-03 00:40:30

标签: php mysql codeigniter

为什么我的代码中出现以下错误?

  

致命错误:在....的写入上下文中不能使用函数返回值。

当我第一次开始使用这个函数时,我在if ... else中有返回语句,而错误似乎与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";
        }
    }
}

1 个答案:

答案 0 :(得分:3)

row()何时成为函数?

尝试:

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