php if statement mysql field value help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Roach
    New Member
    • Feb 2007
    • 1

    php if statement mysql field value help

    Hello all ! (my first post)

    First its safe to assume that I have no idea what I am doing because you would be correct.

    My problem is, I am working in a simple paypal ipn script and I have stored t or f (true or false) in mysql my_config field my_field

    Now in the ipn script I need to know if that info in my_config >my_field is t or f

    I have tried many variations like:

    global $my_config;
    if($my_field !== 't' ){ do this}
    if($my_field !== 'f' ){ do this other}

    Thought it worked till I tried f > it just assumed ? t and did t instead.

    I then tried:
    global $my_config;
    if ($my_config['my_field'] != 't'){ do this}
    if ($my_config[my_field'] != 't'){do this other}

    I am probably a million miles off, and its probably been discussed before, but I really need some help.

    Regards
    Rochelle
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Welcome to The Scripts!

    When you want to test a variable for a value, don't use the negative check, do the positive check, like this:
    [php]if ($my_config['my_field'] == 't'){ do your things for the 't' value}
    if ($my_config['my_field'] == 'f'){ do your things for the 'f' value}
    [/php]
    Ronald :cool:

    Comment

    Working...