1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ErrorException: Undefined index: known

Discussion in 'XenForo Development Discussions' started by AndyB, Feb 15, 2015.

  1. AndyB

    AndyB Well-Known Member

    I have the following code in my Register Email add-on:

                        // get location
    $tags get_meta_tags('http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=' $ipAddress);

    // define location only if we have data
    if ($tags['known'] == 'true')
    $location $tags['city'] . ', ' $tags['region'] . ', ' $tags['country'];
    The following line:

    if ($tags['known'] == 'true')
    very rarely will produce a server error message. What is the proper way to code this so in case the index is undefined, it will not produce an error message?

    Thank you.
  2. Chris D

    Chris D XenForo Developer Staff Member

    Use isset() or empty()
    Marcus likes this.
  3. AndyB

    AndyB Well-Known Member

    Thank you, Chris.

Share This Page