I'm just starting to learn PHP and I'm trying to send my table via email. I am receiving the email but the body just says Array. I dont know where to go from here, please help.
This is how my table is being displayed, and the send mail function in there as well
<form action="assign.php" method="post"><?php
if(is_array($result)){
echo '
<fieldset> <legend>Assign Ticket</legend> <div>Changes will affect updated rows only.</div> <p></p> <table width=auto cellpadding=1px cellspacing=0px border=1 align=center id=assign> <thead> <tr>';
// column comment from DB as column header
foreach($result[0] as $key => $val){
echo '<th align=center>'.$colcomments[$key].'</th>';
}
echo '
</tr> </thead> <tbody>';
foreach($result as $row => $info){
echo '<tr>';
foreach($info as $key => $val){
if($key=='id'){
echo '<td title="'.$colcomments[$key].'">'.$val.'.<input type="hidden" name="'.$key.'['.$info['id'].']" value="'.$val.'" id="rowid_'.$val.'" /></td>';
}
else {
echo '<td title="'.$colcomments[$key].'"><input type="text" name="'.$key.'['.$info['id'].']" value="'.$val.'" /></td>';
}
}
echo '</tr>';
}
echo '
</tbody> </table> </fieldset>';
if($result) {
$Body = "<html>\n"
. "<head>\n"
. "</head>\n"
. "<body>\n"
. $result
. "</body>\n"
. "</html>\n";
//Setting up Mail
$mail = new PHPMailer();
if (EMAIL_USE_SMTP) {
// Set mailer to use SMTP
$mail->IsSMTP();
//useful for debugging, shows full SMTP errors
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
// Enable SMTP authentication
$mail->SMTPAuth = EMAIL_SMTP_AUTH;
// Enable encryption, usually SSL/TLS
if (defined(EMAIL_SMTP_ENCRYPTION)) {
$mail->SMTPSecure = EMAIL_SMTP_ENCRYPTION;
}
// Specify host server
$mail->Host = EMAIL_SMTP_HOST;
$mail->Username = EMAIL_SMTP_USERNAME;
$mail->Password = EMAIL_SMTP_PASSWORD;
$mail->Port = EMAIL_SMTP_PORT;
} else {
$mail->IsMail();
}
$mail->From = EMAIL_FROM_ADDRESS;
$mail->FromName = EMAIL_FROM_NAME;
$mail->AddAddress('sample.test@domain.COM');
$mail->Subject = 'Ticket Assignment - ';
$mail->WordWrap = 100;
$mail->IsHTML(true);
$mail->Body = $Body;
$mail->Send();
}
}
?> <fieldset> <legend>Select Date</legend> <div>Select Date from and Date to</div> <p></p> <input type="date" name="from" id="from" value="<?=$date['from']; ?>" /> <input type="date" name="to" id="to" value="<?=$date['to']; ?>" /> <div><input type="submit" value="Submit" /></div> </fieldset> </form>
Here is the smtp debug result that I am getting,
Notice: Array to string conversion in C:\*\assign.php on line 260
Which refers to this,
. "</body>\n"