Some help with this please

Discussion in 'PHP' started by Jim bob 9 pants, Apr 29, 2007.

  1. #1
    Hi

    I have an email script that can be triggered without a recipent address, so I want I think an if or else statment to default it to my address if its triggered by mistake.?

    I have a data base of email addresses and I want a bit of code that checks to see if

    row_rs_details['email']

    exsists if, not then siwtch to my default of

    Hope that makes sense

    Jim bob
     
    Jim bob 9 pants, Apr 29, 2007 IP
  2. sky22

    sky22 Guest

    Messages:
    59
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,

    You need to use the isset function to check if the variable exists and you might want to check it's not empty too. To check it's not empty you can use the empty() function, heres an example:

    
    
    if( !isset ( $row_rs_details['email']  ) || empty( $row_rs_details['email'] ) )
         $row_rs_details['email'] = 'me@me.com';
    
    
    Code (markup):
    Sky22
     
    sky22, Apr 29, 2007 IP
    Jim bob 9 pants likes this.
  3. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thank you

    if I want the result to be a variable ie $email

    can I do

    $email= if( !isset ( $row_rs_details['email']  ) || empty( $row_rs_details['email'] ) )
         $row_rs_details['email'] = 'me@me.com';
    PHP:
    seems I cant.....
     
    Jim bob 9 pants, Apr 29, 2007 IP
  4. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ignore the above, I dont need a variable as the last line already does it for me
     
    Jim bob 9 pants, Apr 29, 2007 IP