1

I have this function on my code, and give me this error:

syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ')' on line 25

I cant find the error maybe you can see what I can't D:

public function InsertHero()
    {
        $this->load->view('Header');
        $this->load->view('HeroForm');
        $this->load->view('Footer');

        $data = array(
        'Name' -> $this -> input -> post('nick'), //this is the line 25
        'Power' -> $this -> input -> post('superpower'),
        'Phone' -> $this -> input -> post('phone'),
        'Email' -> $this -> input -> post('mail'),
        'Category' -> $this -> input -> post('category_id')
        );
        $this->model_heroes->insert($data);
        redirect(base_url());
    }
Ali ATriple
  • 179
  • 15

2 Answers2

1

Per Rooney's comment, you do an array like this:

array( "foo" => "bar");

Not this:

array( "foo" -> "bar");
Kevin_Kinsey
  • 2,285
  • 1
  • 22
  • 23
1

Simple error, you have used the operator for classes/objects (T_OBJECT_OPERATOR is ->) in your array declaration, when you should have used the T_DOUBLE_ARROW => operator.

Therefore your array should look like;

$data = array('Name' => $this->input->post('nick'));

For reference PHP operators

Rooneyl
  • 7,802
  • 6
  • 52
  • 81