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.

PHP mail() function problem

Discussion in 'PHP' started by XandroZ, Oct 30, 2007.

  1. #1
    I get a T_IF errore something wrong with the if but I don't understand why.
    Here is a part of the code,where I think the error ocure.

    
    $fields = array();
    $fields{"email"} = "email";
    $fields{"serial"} = "serial";
    $fields{"schedamadre"} = "schedamadre";
    $fields{"processore"} = "processore";
    $fields{"schedaaudio"} = "schedaaudio";
    $fields{"schedarete"} = "schedarete";
    $fields{"cddvd"} = "cddvd"; 
    $fields{"descrizione"} = "descrizione"; 
    $fields{"errore"} = "errore"; 
    $fields{"programmi"} = "programmi"; 
    $fields{"nome"} = "nome"; 
    $fields{"cognome"} = "cognome"; 
    $fields{"indirizzo"} = "indirizzo"; 
    $fields{"citta"} = "citta"; 
    $fields{"provincia"} = "provincia"; 
    $fields{"telefono"} = "telefono"; 
    $body = "We have received the following information:\n\n";
     foreach($fields as $a => $b)
     { $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 
     $time = date('l dS \of F Y h:i:s A');
    $email_subject = "New contact message from ".$site_name."";
    $sender=mail($admin_email,$email_subject,$body,"From:$check_email,Reply-to:$check_email") 
    if($sender) { header("Location: index.php?status=1"); }
     else {
    header("Location: index.php?status=0");
    }
    
    
    Code (markup):

     
    XandroZ, Oct 30, 2007 IP
  2. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #2
    1. You missed a semicolon before if.
    2. It was a surprise for me you use curve brackets {} for accessing array members and it works! I always use square ones [] for that.
     
    wmtips, Oct 30, 2007 IP
  3. Lordy

    Lordy Peon

    Messages:
    1,643
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #3
    :) I hate when you're looking through your code and you just can't figure it out, because its a = or == error.

    but an missing semicolon should atleast tell you the line :p which makes it easier.
     
    Lordy, Oct 30, 2007 IP
  4. LimeBlast

    LimeBlast Peon

    Messages:
    81
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Go to php.net/mail to get help!
     
    LimeBlast, Mar 23, 2008 IP