I am trying for send mail using php.Mail body part contain data taken from database with while loop.It shows error.Error is Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) .Error shown in body part.Ie line $fet['date']; in body part.How i slve these issue? Can i send mail with these body contain html and php code?
我正在尝试使用php发送邮件。邮件正文部分包含从while循环数据库中获取的数据。它显示错误。错误是Parse错误:语法错误,意外'' (T_ENCAPSED_AND_WHITESPACE),期望标识符(T_STRING)或变量(T_VARIABLE)。身体部分显示错误。如行$ fet [' date'];在身体部分。我如何解决这些问题?我可以发送包含html和php代码的邮件吗?
我邮件的正文部分是
$messag=echo "<table width='98%' border='0'
cellspacing='1' cellpadding='4' align='center' class='greyBorder' >
<tr class='blueBackground'>
<td width='4%' align='left' bgcolor='#4096AF'><strong>No.</strong></td>
<td width='20%' align='left' bgcolor='#4096AF'><strong>Date</strong></td>
<td width='20%' align='left' bgcolor='#4096AF'><strong>Sale</strong></td>
<td width='20%' align='left' bgcolor='#4096AF'><strong>Payment</strong></td>
</tr>
$si=1;
while($fet=mysql_fetch_array($sql3))
{
$className = ($className == 'evenRow')?'oddRow':'evenRow';
<tr class='$className'>
<td class='txt'> $si;</td>
<td class='txt'>
$fet['date'];
</td>
<td class='txt'>
$fet['total'];
</td>
<td class='txt'> $fet['net_amount'];
</td>
</tr>
$si=$si+1;
}
$className = ($className == evenRow)?oddRow:evenRow;
<tr align='right' class=' print $className'>
<td colspan='9'><table width='100%' border='0' cellspacing='0'cellpadding='0'>
<tr>
<td width='50%' align='center' class='txt'> $pagination </td>
</tr>
</table>
</td>
</tr>
</table>";
有人为这个问题提供任何解决方案吗?
答案 0 :(得分:1)
你使用错误的syntex所有代码都用引号覆盖,所以php无法解析它。
请尝试以下代码:
$message="<table width='98%' border='0'
cellspacing='1' cellpadding='4' align='center' class='greyBorder' >
<tr class='blueBackground'>
<td width='4%' align='left' bgcolor='#4096AF'><strong>No.</strong></td>
<td width='20%' align='left' bgcolor='#4096AF'><strong>Date</strong></td>
<td width='20%' align='left' bgcolor='#4096AF'><strong>Sale</strong></td>
<td width='20%' align='left' bgcolor='#4096AF'><strong>Payment</strong></td>
</tr>";
$si=1;
while($fet=mysql_fetch_array($sql3))
{
$className = ($className == 'evenRow')?'oddRow':'evenRow';
$message .="<tr class='$className'>
<td class='txt'> $si;</td>
<td class='txt'>
".$fet['date']."
</td>
<td class='txt'>
".$fet['total']."
</td>
<td class='txt'> ".$fet['net_amount']."
</td>
</tr>";
$si=$si+1;
}
$className = ($className == evenRow)?oddRow:evenRow;
$message .= "<tr align='right' class='".$className."'>
<td colspan='9'><table width='100%' border='0' cellspacing='0'cellpadding='0'>
<tr>
<td width='50%' align='center' class='txt'> ".$pagination." </td>
</tr>
</table>
</td>
</tr>
</table>";