Jump to content

Recommended Posts

I have a basic mysql query that will return multiple results using mysql_fetch_row.  I want those results to be inserted in the the "$mail_body" portion of the email that is going out.  I cannot get this to work.  The only thing that will work is if I just use a standard "$variable" variable in the "$mail_body".  Can someone me with this?  Let me know if I need to elaborate.  Thank you.

 

<?php

$Name = "Da Duder"; //senders name
$email = "[email protected]"; //senders e-mail adress
$recipient = "[email protected]"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command 
?>

Does the text you are returning from the DB have any html tags in it? as I think this would cause it to fail.

 

You could try adding these to the headers

 

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

 

which should let it send ok. (its been a while since i have used e-mails with php though)

I want the results of this query, to be sent in the $mail_body. 

 

include("dbinfo.$companyname.inc.php");
mysql_connect("localhost",$uname,$pword)
or die("cannot connect");
mysql_select_db("$database")or die("cannot select DB");

$query45 = "SELECT itemspurchased FROM items WHERE ID = '1' LIMIT 1"; 
$result45=mysql_query($query45);
$num45=mysql_numrows($result45);
while ($row45 = mysql_fetch_row($result45))
{
 $itemspurchased = $row45[0];
}
								}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.