PHP数组通知未定义索引-它已定义?
我很难理解一个代码,我的意思是它应该可以正常工作 代码如下:PHP数组通知未定义索引-它已定义?,php,arrays,Php,Arrays,我很难理解一个代码,我的意思是它应该可以正常工作 代码如下: foreach( $_POST['wageline'] AS $line ){ print_r( $line ); if( !$MySQL->Query(" INSERT INTO wages_lines SET 'bat
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'] . "'
") )
我的打印结果如下:
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
)
尽管如此,我还是收到了如下通知:
注意:未定义索引:第573行/var/www/vhosts/ontimebemanning.no/portal.ontimebemanning.no/modules/core.sweers/classes/sweeg.class.php中的名称
注意:未定义索引:第574行/var/www/vhosts/ontimebemanning.no/portal.ontimebemanning.no/modules/core.sweers/classes/sweeg.class.php中的标识号
显然,它们是有定义的,所以我不知道为什么我的剧本会朝我的脸上扔通知。
有人有线索吗?您的代码有错误。您在查询代码中使用的是
=>
而不是=
。您的代码中有一个错误。您在查询代码中使用的是=>
而不是=
。如果这是print\r()
的输出,则POST请求中发送的数据在关键字名称周围有引号;要立即访问数据,您必须执行以下操作:
echo $lines["'name'"];
或者,更可取的是,找出传输这些额外引号的原因并删除它们。如果这是
print\r()
的输出,则POST请求中发送的数据在关键字名称周围有引号;要立即访问数据,您必须执行以下操作:
echo $lines["'name'"];
或者,更可取的是,找出这些额外的引号被传输的原因并删除它们。['identity\u number']=>['account']=>它们似乎没有定义me@MarcoMura值似乎未定义,但键仍然是present@MarcoMura它们已定义但未指定值值未定义,是,但索引未定义。它还会在包含值的索引上抛出undefinex索引错误。当我使用print\r时,我看不到引号。我看到类似于[key]=>value的东西。因为您看到的是引号,它告诉我您在键值中嵌入了引号,或者您手工键入并添加了引号。如果引号位于键值中,如图所示,则不定义没有引号的键。['identity_number']=>['account']=>它们似乎未定义me@MarcoMura值似乎未定义,但键仍然是present@MarcoMura它们已定义但未指定值值未定义,是,但索引未定义。它还会在包含值的索引上抛出undefinex索引错误。当我使用print\r时,我看不到引号。我看到类似于[key]=>value的东西。因为您看到的是引号,它告诉我您在键值中嵌入了引号,或者您手工键入并添加了引号。如果引号位于键值中,如图所示,则不定义没有引号的键。但是,未定义索引的问题仍然存在。如果问题中出现了错误,并且没有直接解决实际问题,或者与问题无关,则不要将该问题的解决方案作为答案发布,而是发布注释。一个问题的答案应该回答这个问题,而不是你发现的可能有一点用处的随机事物。但是,未定义索引的问题仍然表明问题中存在错误,没有直接解决实际问题,或者与问题无关,不要发布解决方案作为答案,而是发布评论。问题的答案应该是这个问题的答案,而不是你发现的可能有一点用处的随机事件。谢谢你,确实如此=)谢谢你,确实如此=)