1

Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”
Undefined index in PHP

Notice: Undefined index: NAME in C:\xampp\htdocs\pmsx\lib\config.php on line 107

That's the exact error. Here's my code on the file. Thanks for those will help.

here's my line 107:

//echo "<br>" . $cdata;
// create the proper tree node if NAME attribute is set
if ($this->attr["NAME"] != "")
    $this->tags[count($this->tags) - 1] = $this->attr["NAME"];

Pastie link

Community
  • 1
  • 1
Karl
  • 13
  • 5

3 Answers3

0

NAME isn't a defined index. You probably want:

if( isset($this->attr['NAME']) && $this->attr['NAME'] != "" ) {
    // ...
Cfreak
  • 19,191
  • 6
  • 49
  • 60
0

What you probably want is !empty($this->attr['NAME']) instead of $this->attr["NAME"]!="". Otherwise it errors out when NAME index is… well… undefined.

Michael Krelin - hacker
  • 138,757
  • 24
  • 193
  • 173
0

Use isset() first, to check, whether the property exists at all.

if ( isset( $this->attr["NAME"] ) && ($this->attr["NAME"] != "") ) {
    $this->tags[count($this->tags) - 1] = $this->attr["NAME"];
}

You error says, that the property NAME does not exist at all in the array attr!

Sirko
  • 72,589
  • 19
  • 149
  • 183