php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9926 Warning: Undefined index: Service[1]
Submitted: 2001-03-22 10:44 UTC Modified: 2001-03-22 10:51 UTC
From: john at neutralize dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.0.4pl1 OS: Windows 98
Private report: No CVE-ID: None
 [2001-03-22 10:44 UTC] john at neutralize dot com
I am dynamically creating input fields in my form with their values stored in an array:

<input type="Hidden" name="Service[<?php echo $counter ?>]" value="<?php echo odbc_result($result, "ServiceId") ?>">

These submit fine but I am having trouble accessing the results of the array from the post variables:

$serviceId = $HTTP_POST_VARS["Service[".$counter."]"]; OR
$serviceId = $HTTP_POST_VARS['Service['.$counter.']']; OR
$serviceId = $HTTP_POST_VARS['Service[.$counter.]'];   OR
$serviceId = $HTTP_POST_VARS["Service[.$counter.]"];

How do I reference the values in PHP if not like this?

When using var_dump($HTTP_POST_VARS); I get the following:

array(11) { ["Action"]=> string(1) "2" ["Quote"]=> string(2) "38" ["Service"]=> array(13) { [1]=> string(1) "1" [2]=> string(1) "2" [3]=> string(1) "3" [4]=> string(1) "4" [5]=> string(1) "5" [6]=> string(1) "6" [7]=> string(1) "7" [8]=> string(1) "8" [9]=> string(1) "9" [10]=> string(2) "10" [11]=> string(2) "11" [12]=> string(2) "12" [13]=> string(2) "13" } ["From"]=> array(13) { [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(0) "" [8]=> string(0) "" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" [12]=> string(0) "" [13]=> string(0) "" } ["To"]=> array(13) { [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(0) "" [8]=> string(0) "" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" [12]=> string(0) "" [13]=> string(0) "" } ["NoServices"]=> array(13) { [1]=> string(1) "0" [2]=> string(1) "0" [3]=> string(1) "0" [4]=> string(1) "0" [5]=> string(1) "0" [6]=> string(1) "0" [7]=> string(1) "0" [8]=> string(1) "0" [9]=> string(1) "0" [10]=> string(1) "0" [11]=> string(1) "0" [12]=> string(1) "0" [13]=> string(1) "0" } ["NoUnits"]=> array(13) { [1]=> string(1) "0" [2]=> string(1) "0" [3]=> string(1) "0" [4]=> string(1) "0" [5]=> string(1) "0" [6]=> string(1) "0" [7]=> string(1) "0" [8]=> string(1) "0" [9]=> string(1) "0" [10]=> string(1) "0" [11]=> string(1) "0" [12]=> string(1) "0" [13]=> string(1) "0" } ["Comment"]=> array(13) { [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(0) "" [8]=> string(0) "" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" [12]=> string(0) "" [13]=> string(0) "" } ["Use"]=> array(1) { [9]=> string(3) "Yes" } ["ServiceCount"]=> string(2) "13" ["Submit"]=> string(6) "Submit" }

These being the values for service:

["Service"]=> array(13) { [1]=> string(1) "1" [2]=> string(1) "2" [3]=> string(1) "3" [4]=> string(1) "4" [5]=> string(1) "5" [6]=> string(1) "6" [7]=> string(1) "7" [8]=> string(1) "8" [9]=> string(1) "9" [10]=> string(2) "10" [11]=> string(2) "11" [12]=> string(2) "12" [13]=> string(2) "13" } 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-22 10:51 UTC] hholzgra@php.net
oj, stupid me, not my day :(

$serviceId = $HTTP_POST_VARS['Service'][$counter];

that's what you are looking for
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC