Codeigniter消息:使用未定义的常量

Hear is my code that i used.

$data = array(  question=>$this->input->post('questions'),
                answer1=>$this->input->post('answer1'),
                answer2=>$this->input->post('answer2'),
                answer3=>$this->input->post('answer3'),
                answer4=>$this->input->post('answer4'),
                answer5=>$this->input->post('answer5'),
                correctanswer=>$this->input->post('correctanswer')
             );
$this->db->insert('questionandanswers',$data);

Please provide help for this notice message.

A PHP Error was encountered

Severity: Notice
Message: Use of undefined constant question - assumed 'question'

You need to add single quote on array key because it consider array key question as constant.

Your array should be like..

  $data = array(
          'question'=>$this->input->post('questions'),
          'answer1'=>$this->input->post('answer1'),
          'answer2'=>$this->input->post('answer2'),
          'answer3'=>$this->input->post('answer3'),
          'answer4'=>$this->input->post('answer4'),
          'answer5'=>$this->input->post('answer5'),
          'correctanswer'=>$this->input->post('correctanswer')
      );
   $this->db->insert('questionandanswers',$data);

Put single or double quotes on array index because array index is either numeric or string, and string is defined using quotes. So change the code like:

$data =

array(
'question'=>$this->input->post('questions'),
'answer1'=>$this->input->post('answer1'),
'answer2'=>$this->input->post('answer2'),
'answer3'=>$this->input->post('answer3'),
'answer4'=>$this->input->post('answer4'),
'answer5'=>$this->input->post('answer5'),
'correctanswer'=>$this->input->post('correctanswer'));

$this->db->insert('questionandanswers',$data);

Array string key must be quoted. In your array 'question', 'answer1' must be quoted. For example 'question'=>$this->input->post('questions')

Need to all array key single or double quotes like bellow :

$data = array(
          "question"=>$this->input->post('questions'),
          "answer1"=>$this->input->post('answer1'),
          "answer2"=>$this->input->post('answer2'),
          "answer3"=>$this->input->post('answer3'),
          "answer4"=>$this->input->post('answer4'),
          "answer5"=>$this->input->post('answer5'),
          "correctanswer"=>$this->input->post('correctanswer')
);
$data = array(question=>$this->input->post('questions'),answer1=>$this->input->post('answer1'),answer2=>$this->input->post('answer2'),answer3=>$this->input->post('answer3'),answer4=>$this->input->post('answer4'),answer5=>$this->input->post('answer5'),correctanswer=>$this->input->post('correctanswer'));$this->db->insert('questionandanswers',$data);

What is question here you need to use question and other indexes as a string like

array('question' => $this->input->post('questions'))

You are missing the array syntax

$data = array(  'question'=>$this->input->post('questions'),
                'answer1'=>$this->input->post('answer1'),
                'answer2'=>$this->input->post('answer2'),
                'answer3'=>$this->input->post('answer3'),
                'answer4'=>$this->input->post('answer4'),
                'answer5'=>$this->input->post('answer5'),
                'correctanswer'=>$this->input->post('correctanswer'));
$this->db->insert('questionandanswers',$data);