#1
  1. No Profile Picture
    inexperienced and useless
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    Stevenage, uk
    Posts
    10
    Rep Power
    0

    do i need to define something that a value is already defined to?


    I have a cgi and i have managed to get the radio buttons working, and can print their value. Eg the button is searchtype and it's value could be substructure.
    So when I write:
    print searchtype
    substructure is printed.

    However if I type:
    if searchtype == substructure:
    Print "the search is substructure"

    I get an error saying that substructure is not defined, how do I get around this does anyone know?

    Cheers,

    NiCkNaMe
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    St. George, Utah
    Posts
    63
    Rep Power
    37
    Do this instead:

    Code:
    if searchtype == "substructure": 
        print "the search is substructure"
    If you don't have quotes around "substructure," Python thinks that it is a variable name and tries to look up the value of it to compare with the value of searchtype. As there is no variable "substructure" defined, you get an error. Putting quotes around it makes it a string literal.
    Lucas Marshall

IMN logo majestic logo threadwatch logo seochat tools logo