Brad
Brad

Reputation: 12272

receiving error undefined index on two variables

Using adLDAP.php class

receiving following error: Notice: Undefined index: memberof in /web/ee_web/include/adLDAP.php on line 762

line 762: if (is_array($groups[0]["memberof"])) {

Also receiving error: Notice: Undefined index: count in /web/ee_web/include/adLDAP.php on line 982

line 982: $entries[0]["memberof"]["count"]++;

Unsure of what I need to do to resolve these error messages, it seems that the script is working fine, but I'd like get rid of these errors.

Using: http://adldap.sourceforge.net/wiki/doku.php?id=api

Upvotes: 0

Views: 1049

Answers (2)

ashurexm
ashurexm

Reputation: 6335

You could edit the code to something along the lines of:

if(isset($groups[0]["memberof"]))
{
    if (is_array($groups[0]["memberof"])){ ... }
}

And

if(isset($entries[0]["memberof"]["count"]))
{
    $entries[0]["memberof"]["count"]++;
}

It will keep you from getting the errors, though it won't necessarily handle some pretty lax sanity checking by the original author of the code.

Upvotes: 2

Seb
Seb

Reputation: 25157

It seems like you have your error_level set to show every possible error/warning/notice, that's why you're getting it.

If the script is working fine, then it's not an error, simply a missing check the coder forgot to put in the library.

To get rid of thos messages, you have 2 options:

a) Use @ before the calls you do to that library, such as

$var = @the_function(param1);

This will avoid those messages for just that line.

b) Set the error level to something like this with error_reporting():

error_reporting(E_ALL ^ E_NOTICE);

This will affect the whole script you're running.

It's up to you what to use depending on the project.

Upvotes: 0

Related Questions