Jump to content

[SOLVED] Second variable in combine string is ignored...


bubbasheeko

Recommended Posts

$newLine = "\r\n";

// FIRST THING - GRAB THE EMAIL LIST

	$email_pull = mysql_query('SELECT * FROM `mail_list`') or die('There was an error connecting to the database to retrieve the email list');

	// CREATE EMAIL GROUP VARIABLE
	$to = "";

	while($email_results = mysql_fetch_assoc($email_pull))
	{
		$email_address = $email_results['email_address'];
		$name = $email_results['name'];
		$to .= "BCC: $name <$email_address>" . $newLine;

	}

	echo $to;

 

I am trying to build an email list pulled from a database for a newsletter.  When I try to combine name and email address the second variable is always ignored....so for example it should be  BCC: My Name <my@email>.... but that is not what is happening.  What is displaying is:  BCC: My Name.

 

email_address is not blank - if I swap the variables,  email address is displayed and name is ignored.

 

I did discover that if I removed the <> it would work fine...but of course I want to be able to have the name and email address showing in the email client.

 

I have tried this way as well:  "BCC: " . $name . "<" . $email_address . ">" . $newLine;  - I get the same results.

 

Anybody see the error of my ways?

If you are echoing it to the screen, it is because of the < and > they are taken by html as a tag.

 

      echo "<pre>" . $to . "</pre>";

will show it, alternative you could view the source and see it as well.

 

I take it this is for debugging, but if you want it to display in HTML, you can use htmlentities to convert the < and > to it's html code to display properly.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.