1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problem with detecting an empty field

Discussion in 'PHP' started by mahmood, Sep 4, 2005.

  1. #1
    I am trying to detect an empty filed in mysql but seems that I am doint something wrong:

    I tried both these codes:
    
    if ($myVariable != "")
    
    PHP:
    and
    
    if (isset($myVariable))
    
    PHP:
    But even when the field is empty they return true.

    What am I doing wrong?
     
    mahmood, Sep 4, 2005 IP
  2. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Have you echoed the var to see what is in it? Do you know what the variable is being type cast as by php?

    I'd try those two debugging ideas.
     
    noppid, Sep 4, 2005 IP
  3. LGRComp

    LGRComp Well-Known Member

    Messages:
    516
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    195
    #3
    Odds are the variable is a space. Try using this it might work.

    You might want to add both isset and empty.

    Good Luck.
     
    LGRComp, Sep 4, 2005 IP
  4. mahmood

    mahmood Guest

    Messages:
    1,228
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for replies

    Apparently the problem was with the logic. I would get the correct result but I expected vice versa.
     
    mahmood, Sep 4, 2005 IP