Jump to content

Recommended Posts

I have a function which generates an email message.

The email is sent but not my variable information.

i know 4e and $v_id are correctly populated.

How can i debug this?

function  vendor_email($e,$v_id)
{		

		$user_id=$v_id;
			$connection = db_connect();    
   			$query = "select * from users where user_id='$user_id'";
   			$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
   			if (!$result)
     			return false;
		   while($row=mysql_fetch_assoc($result))
		   {
			$first_name=$row['first_name'];
   				$last_name=$row['last_name'];

		}
   			//prepare message
		$body="The Vendor details you requested are as follows:-\n";
	 	$body.="Name:-";
		$body.=$first_name;

    	
	 mail($e, 'Vendor Details', $body, 'From: admin@www.homeownersdirect.com');

}	       	  

Link to comment
https://forums.phpfreaks.com/topic/62650-problem-generating-email/
Share on other sites

I don't see anything wrong.

 

Feel free to pick at my code that I've never had problems with.

<?php
dbconnect();
$query = "SELECT * FROM users WHERE id='$id'";
$result = mysql_query($query) or DIE(mysql_error());
if ($result) {
$r = mysql_fetch_assoc($result);
$un = $r["username"];
$em = $r["email"];
}
dbclose();

$to = $em;
$subject = "Registration Complete";
$msg = "<html>
<head>
<title>Registration Complete</title>
</head>
<body>
<p>Username: $un</p>
<p>Password: Not given to protect your account.</p>
<p>E-mail: $em</p>
<p>This is a one time e-mail to inform you of the information that you gave. You will not get this e-mail again.</p>
<p>If you have any questions, contact the webmaster via the site.</p>
</body>
</html>";
$msg = wordwrap($msg, 70);
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .= "From: Webmaster <webmaster@domain.tld>\r\n";
// SEND THE EMAIL
ini_set(sendmail_from, $email);
mail($to, $subject, $msg, $headers);
ini_restore(sendmail_from);
?>

 

Also, I don't think you need to use a while loop for a mysql_fetch_assoc. It's returning just one row. You can just take that out of the while loop like you see in the code I gave as an example.

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.