Results 1 to 3 of 3

Thread: How 2 specify conditions in the Message of the mail body

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    9

    Question How 2 specify conditions in the Message of the mail body

    Hi Everyone ,
    I am posting my first message regarding the Contents of the Message in a body used for emailing in PHP

    Just after the <TD> i have a condtion which checks whether a value exists in a variable or not, if it exists then display 1.gif and if there's nothing in the variable then display 2.gif. But the following code of mine gives a Parse Error.

    i have my message set as
    /* message starts here*/
    $message = '
    <table width=760 border=0 cellspacing=0 cellpadding=0>
    <tr>
    <td valign=top>'.
    if($var=="abc")
    {
    .'<img src=1.gif>'.
    }
    else
    {
    .'<img src=2.gif>'.
    }
    .'</td>'
    /*message ends here*/

    I get an error on the line where i am concatinating 1.gif.
    Could any one explain whats the problem in my code

    Thnx
    Regards,
    S.M.Sajjad

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    That's illegal syntax. Try:

    Code:
    /* message starts here*/
    $message = '<table width="760" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td valign="top">';
    
    if($var=="abc") {
        $message .= '<img src="1.gif">';
    } else {
        $message .= '<img src="2.gif">';
    }
    
    $message .= '</td>';
    /*message ends here*/
    Also of note, I believe it is invalid HTML to not have your attributes quoted. So I added those in there.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    9
    Thnx a lot Hobo !!!
    That did help me solve my problem...
    how stupid of me, I almost forgot this approach
    Anywayz Thnx a Lot....
    Regards,
    S.M.Sajjad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width