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


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


刚开始使用此函数时,我在if ... else中有return语句,该错误似乎与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";
        }
    }
}

最佳答案

row()什么时候成为函数?

尝试:

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

关于php - 致命错误:无法在以下情况的写入上下文中使用函数返回值:,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9985698/

10-10 23:38
查看更多