-2

I have a controller called article in mvc framework codeigniter.

This controller was without error till I uploaded to a host.

This is the error:

Fatal error: Can't use method return value in write context in /home/focusweb/public_html/cms/application/controllers/administrator/article.php on line 17

And my controller: (There is a problem in line 17 But it works in localhost)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Article extends CI_Controller {

public function index() {
    $this->home();
}
public function home() {

    if($this->session->userdata('is_logged_in')){
        $this->load->view("site_header");
        $this->load->model("db_login");
        $data['first_name'] = $this->db_login->get_name($user_id);
        $this->load->view("site_nav", $data);
        $user_id = $this->session->userdata('uid'); 
        $data['name'] = "";
        if(isset($this->input->post("mysubmit"))){
            $data['name'] = $this->input->post("name");
            $data['content'] = $this->input->post("content");
        }


        $this->load->model("db_new_category");        
        //get hierarchal data from database
        $get_all_category = $this->db_new_category->get_all_category();
        //manage hierarchal data and send them to view
        $this->load->model("hierarchy");

        $this->load->model("db_new_category");        
        $get_all_category = $this->db_new_category->get_all_category();
        $this->load->model("hierarchy");
        $data1 = $this->hierarchy->get_hierarchy($get_all_category, 'category_name_db', 'deep', 'id', 'count');
        $data = $data + $data1;
        $this->load->view("add_article", $data1);
        $this->load->view("site_footer");
    }
    else redirect('administrator/login');
}

Line 17 is here:

if(isset($this->input->post("mysubmit"))){
tereško
  • 58,060
  • 25
  • 98
  • 150
Vahid Najafi
  • 4,654
  • 11
  • 43
  • 88
  • 1
    Please copy-paste the code here as text, not as a screenshot. – JJJ Jan 31 '15 at 18:46
  • possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – deceze Feb 01 '15 at 11:25

1 Answers1

2

Use this code instead. if you use CI version less than 3.0

if ( $this->input->post("mysubmit") !== false ) {

If CI greater than or equal to 3.0 then

if ( $this->input->post("mysubmit") !== NULL ) {
Ahsaan Yousuf
  • 685
  • 7
  • 16
  • Thank you. Not only your code, but also when I define `$this->input->post('mysubmit')` as a variable and use it into `if` it works. By the way, thanks a lot :) – Vahid Najafi Jan 31 '15 at 19:17