我一直在尝试为drupal网站创建一个非常简单的表单,表单正确显示所有字段。当试图将信息保存到数据库时,我得到一个错误。
我得到:PHP Parse错误:语法错误,意外' - >'第286行(T_OBJECT_OPERATOR)
我一直在关注如何在drupal中保存数据的severel指南,并且所有人都同意我应该使用db_insert而不是带有insert语句的db_query,但对于我的生活,我无法理解为什么我得到这个错误。我一直在看几个例子,包括;
https://www.drupal.org/node/1164398
谁能告诉我它为什么不能存钱?我得到错误?function drupalform_form1_submit($form, &$form_state) {
$values = array(
// CONTACT INFO
'email' => $form_state['values']['email'],
'phone' => $form_state['values']['phone'],
// PARTICIPANT 1 VALUES
'p1name' => $form_state['values']['p1name'],
'p1nationality' => $form_state['values']['p1nationality'],
'p1University' => $form_state['values']['p1University'],
'p1year' => $form_state['values']['p1year'],
// PARTICIPANT 2 VALUES
'p2name' => $form_state['values']['p2name'],
'p2nationality' => $form_state['values']['p2nationality'],
'p2University' => $form_state['values']['p2University'],
'p2year' => $form_state['values']['p2year'],
// PARTICIPANT 3 VALUES
'p3name' => $form_state['values']['p3name'],
'p3nationality' => $form_state['values']['p3nationality'],
'p3University' => $form_state['values']['p3University'],
'p3year' => $form_state['values']['p3year'],
// PARTICIPANT 4 VALUES
'p4name' => $form_state['values']['p4name'],
'p4nationality' => $form_state['values']['p4nationality'],
'p4University' => $form_state['values']['p24niversity'],
'p4year' => $form_state['values']['p4year']
);
$insert = db_insert('bte_handin')->fields(array(
// INSERTING CONTACT INFO
'email' => $values['email'],
'phone' => $values['phone'],
// INSERTING PARTICIPANT 1
'p1name' => $values['p1name'],
'p1nationality' => $values['p1nationality'],
'p1University' => $values['p1University'],
'p1year' => $values['p1year'],
// INSERTING PARTICIPANT 2
'p2name' => $values['p2name'],
'p2nationality' => $values['p2nationality'],
'p2University' => $values['p2University'],
'p2year' => $values['p2year'],
// INSERTING PARTICIPANT 3
'p3name' => $values['p3name'],
'p3nationality' => $values['p3nationality'],
'p3University' => $values['p3University'],
'p3year' => $values['p3year'],
//INSERTING PARTICIPANT 4
'p4name' => $values['p4name'],
'p4nationality' => $values['p4nationality'],
'p4University' => $values['p4University'],
'p4year' => $values['p4year'],
))->execute(); This is where the error is occuring
drupal_set_message("Your answer has ben saved");
}