On Thu,  7 Oct 2004 14:04:00 +0800, Roger Thomas <[EMAIL PROTECTED]> wrote:
> I have this short script (below) that does checking whether a userid has an 
> associated jpegPhoto in an LDAP database. The script is working fine but gave a 
> 'Notice' msg bcos I made error_reporting to report all errors.
> 
> Notice: Undefined index: jpegphoto in test.php on line 34
> 
> Question: How do I make the Notice go away without changing error reporting to 
> error_reporting (E_ALL & ~E_NOTICE) ?
> [...]
>         $photo     = $resultEntries[0]["jpegphoto"];

It's complaining because you're trying to read from an array index
that hasn't been set, Assuming this isn't a typo or something, if you
want to avoid the notice you normally have two options:

  1. initialise all the indexes that you plan to use.
  2. check whether the index has been set before you try to read from it.

In this case, you're pretty much stuck with the second option as
you're getting the array from an external source.

So do something like this:

  $photo = isset($resultEntries[0]["jpegphoto"]) ?
$resultEntries[0]["jpegphoto"] : array('count' => 0);

  -robin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to