CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006
    Posts
    306

    PHP Notice: Undefined Index

    Okay, I keep getting this error when someone accesses the file.
    Code:
    PHP Notice:  Undefined index:  Ex in C:\\Server\\172.16.1.35\\WhosOnline.php on line (2, 3, and 33)
    I noticed that in every line, there is something like this.
    PHP Code:
    if ($_GET["Ex"] == "false") echo "</pre>"
    Now, sometimes, there will not be a ?Ex=false, so I made it to this.
    PHP Code:
    if ($_GET["Ex"])
    {
        if (
    $_GET["Ex"] == "false") echo "</pre>";

    I still get the error that the index is undefined, and this snippet is not working how I thought it would, so how do I check if it is undefined, so it will stop giving me that error.

  2. #2
    Join Date
    Oct 2008
    Location
    Richmond, VA
    Posts
    24

    Re: PHP Notice: Undefined Index

    i think this is what you want:

    Code:
      
    if (isset($_GET["Ex"])) 
    { 
    	if ($_GET["Ex"] == "false") echo "</pre>"; 
    } 
    

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: PHP Notice: Undefined Index

    PHP is a loosely typed language. That means that variable types automatically adapt. You shouldn't need quotes around the false for it to act as boolean.

    PHP Code:
    if (isset($_GET["Ex"])) {
      if (!
    $_GET["Ex"]) {echo "</pre>";}

    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  4. #4
    Join Date
    May 2006
    Posts
    306

    Re: PHP Notice: Undefined Index

    Okay, I knew it was something like isset().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured