using php variables in php mail $message

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Chimera79
Forum Newbie
Posts: 1
Joined: Sun Jul 30, 2006 9:27 am

using php variables in php mail $message

Post by Chimera79 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi peps, i am trying to create a html mail which should display the values from a query but when i use single quote the result is not showed. when i use double quotes i get parse errors. 

this is my a subset of my code;

Code: Select all

$displayName = $row_rcEmailadd['displayname'];
$LoanID = $row_rcLoans['LoanId'];
$mySnum = $row_rcLoans['SerialNumber'];
$BarcodeNumber = $row_rcLoans['BarcodeNumber'];
$Make = $row_rcLoans['Make'];
$Model = $row_rcLoans['Model']; 
$AssetDescription = $row_rcLoans['AssetDescription'];
$itemCon = $row_rcLoans['itemCondition'];
$Purpose = $row_rcLoans['Purpose'];
$Note = $row_rcLoans['Notes'];
$LoanDate = $row_rcLoans['loandate'];
$ReturnDate = $row_rcLoans['ReturnDate'];
?>

<?php
$to = $row_rcEmailadd['EmailAddress'];
$subject = 'Loan Confirmation Details';
//Message body
$message = '
<html lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="something else here">
</head>

<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 bgcolor="#FFFFFF">

<table width="769" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="110" bgcolor="B70004"><img src="s.gif" alt="" width="1" height="5"><br>
      <img src="http://s.gif" alt="" width="2" height="1"><img src="homepage/logo.gif" width="110" height="65" border="0" alt="BSA HOME"><br>
      <img src="trans.gif" alt="" width="1" height="5"></td>
    <td colspan="5" class="HeaderBackground"> 
      <div align="center"><H1>The Ba</H1></div>    </td>
	<td width="110" bgcolor="B70004">&nbsp;	</td>
  </tr>
  
  <tr>
  	<td colspan="7" bgcolor="FFFFFF">	</td>
  </tr>
</table>
	
<div align="center">
  <table width="100%" height="351" border="0" cellpadding="0" cellspacing="5">
    <tr>
      <td width="19%">
        <blockquote>
          <p align="left">&nbsp;</p>
          <p align="left">&nbsp;</p>
          <p align="left">&nbsp;</p>
          <p align="left">&nbsp;</p>
          <p align="left">&nbsp;</p>
      </blockquote>        <p align="left"></p></td>
      <td width="81%">        <table width="487" border="0" cellpadding="0" cellspacing="0">
          
          <?php do { ?>
            <tr>
              <td width="174">Staff Name: </td>
              <td width="313">
			  <?php echo $displayName; ?></td>
            </tr>
            <tr>
              <td>Loan ID: </td>
              <td><?php echo $myLoanID; ?></td>
            </tr>
            <tr>
              <td>Asset Serial Number:</td>
              <td><?php echo $mySnum; ?></td>
            </tr>
            <tr>
              <td>Asset Tag:</td>
              <td><?php echo $BarcodeNumber; ?></td>
            </tr>
            <tr>
              <td>Make:</td>
              <td><?php echo $Make; ?></td>
            </tr>
            <tr>
              <td>Model:</td>
              <td><?php echo $Model; ?></td>
            </tr>
            <tr>
              <td>Description:</td>
              <td><?php echo $AssetDescription; ?></td>
            </tr>
            <tr>
              <td>Present State:</td>
              <td><?php echo $itemCon; ?></td>
            </tr>
            <tr>
              <td>Loan Purpose:</td>
              <td><?php echo $Purpose; ?></td>
            </tr>
            <tr>
              <td height="59">Notes:</td>
              <td><?php echo $myNotes; ?></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>Loan Date </td>
              <td><?php echo $LoanDate; ?></td>
            </tr>
            <tr>
              <td>Return Date </td>
              <td><?php echo $ReturnDate; ?></td>
            </tr>
            <?php } while ($row_rcLoans = mysql_fetch_assoc($rcLoans)); ?>
        </table></td>
    </tr>
  </table>
</div>
<p>&nbsp;</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td bgcolor="#CCCCCC" colspan="2" width="769"><img src="Templates/space.gif" alt=""  width="1" height="1" ></td>
  </tr>
  <tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
  </table>
<br>
</body>
</html>';
when the email is generated the values of the variables are never displayed. Please help.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You've got a solid string from tip to tail. I'd suggest reading up on working with strings.
Post Reply