SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: What is this error?
-
May 12, 2006, 10:54 #1
- Join Date
- Feb 2006
- Posts
- 11
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What is this error?
Notice: Undefined index: 27 in /var/www/html/johnsonpublishing.com/webadmin/members/members_list.html on line 456
This is line 456
$lists_display[] = $lists_array["$lists_ID"];
Here is the entire code
if ($lists != "") {
$lists_display = Array();
$lists = explode(",", $lists);
foreach($lists AS $lists_ID) {
if ($lists_ID != "") {
$lists_display[] = $lists_array["$lists_ID"];
-
May 12, 2006, 10:58 #2
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
its kinda like an undefined variable notice, except its saying the array element is undefined.
given the following array
PHP Code:
$array = array(
'foo' => 5,
'bar' => 5
);
// works, because $array['foo'] exists
echo $array['foo'];
// generates undefined index notice
echo $array['lenora'];
using $array['lenora'] gives the undefined index notice, because there is no 'lenora' element in the array to use.
you can use isset() or array_key_exists() to check if a variable/array element exists. they have slightly different behavior, the php manual explains the difference.
-
May 12, 2006, 12:43 #3
- Join Date
- Feb 2006
- Posts
- 11
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Array reply
Since it doesn't exist why can't I take it out?
-
May 12, 2006, 12:47 #4
- Join Date
- Aug 2000
- Location
- Philadephia, PA
- Posts
- 20,578
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
The error means that on this line
PHP Code:$lists_display[] = $lists_array["$lists_ID"];
Since I can't see the source of the $lists variable that populated $lists_array, I can't tell you where or how you could take out whatever's not being found. As clamcrusher said, you would use array_key_exists() to see if $lists_ID is in $lists_array before assigning it to $lists_display if you want to avoid this notice.Try Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more
-
May 12, 2006, 13:12 #5
- Join Date
- Feb 2006
- Posts
- 11
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've been working on the file for two days now and its still is not right, may I send you the source file so you can tell me what it is I am doing wrong?
Bookmarks