【发布时间】:2014-11-17 13:59:48
【问题描述】:
我无法理解我的意思是应该可以正常工作的代码。
代码如下:
foreach( $_POST['wageline'] AS $line ){
print_r( $line );
if( !$MySQL->Query("
INSERT INTO
wages_lines
SET
'batch_id' = '" . $this->batch_id . "',
'name' = '" . $line['name'] . "',
'identity_number' = " . $line['identity_number'] . "',
'account' = '" . $line['account'] . "',
'phone' = '" . $line['phone'] . "',
'ordinary_hours' = '" . $line['ordinary_hours'] . "',
'fifty_percent' = '" . $line['fifty_percent'] . "',
'hundred_percent' = '" . $line['hundred_percent'] . "',
'mileage' = '" . $line['mileage'] . "',
'remuneration' = '" . $line['remuneration'] . "',
'pall_dag_2' = '" . $line['pall_dag_2'] . "',
'pall_dag_3' = '" . $line['pall_dag_3'] . "',
'pall_natt_2' = '" . $line['pall_natt_2'] . "',
'pall_natt_3' = '" . $line['pall_natt_3'] . "',
'ub_1' = '" . $line['ub_1'] . "',
'ub_2' = '" . $line['ub_2'] . "',
'ub_3' = '" . $line['ub_3'] . "',
'ub_4' = '" . $line['ub_4'] . "',
'ub_5' = '" . $line['ub_5'] . "',
'employee_wage' = '" . $line['employee_wage'] . "',
'brutto_total' = '" . $line['brutto_total'] . "',
'mileage_total' = '" . $line['mileage_total'] . "',
'remuneration_total' = '" . $line['remunerations_total'] . "'
") )
我的 print_r 的结果如下:
Array
(
['name'] => Alexander Fagerstrand
['identity_number'] =>
['account'] =>
['phone'] => 0
['ordinary_hours'] => 32.5
['fifty_percent'] => 0
['hundred_percent'] => 0
['mileage'] => 458
['remuneration'] => 628
['pall_dag_2'] => 0
['pall_dag_3'] => 0
['pall_natt_2'] => 0
['pall_natt_3'] => 0
['ub_1'] => 0
['ub_2'] => 0
['ub_3'] => 0
['ub_4'] => 0
['ub_5'] => 0
['employee_wage'] => 177
['brutto_total'] => 5752.50
['mileage_total'] => 1854.9
['remunerations_total'] => 628
)
不过,我还是收到了这样的通知:
通知:未定义索引:/var/www/vhosts/ontimebemanning.no/portal.ontimebemanning.no/modules/core.wages/classes/wage 中的名称。第 573 行的 class.php
通知:未定义索引:/var/www/vhosts/ontimebemanning.no 中的标识号/portal.ontimebemanning.no/modules/core.wages/classes/wage.class.php 第 574 行
显然,它们是已定义的,所以我不知道为什么我的脚本会向我抛出通知。 有人知道吗?
【问题讨论】:
-
['identity_number'] => ['account'] => 他们对我来说似乎没有定义
-
@MarcoMura 值似乎未定义,但键仍然存在
-
@MarcoMura 它们已定义但未分配值
-
值是未定义的,是的,但索引不是。它还会在包含值的索引上抛出未定义索引错误
-
当我使用 print_r 时,我看不到引号。我看到类似 [key] => value 的东西。因为您看到的是引号,所以它告诉我您在键值中嵌入了引号 - 或者您手动输入并添加了引号。如果引号在键值中,如图所示,不定义不带引号的键。