bubbasheeko Posted April 1, 2009 Share Posted April 1, 2009 $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? Quote Link to comment https://forums.phpfreaks.com/topic/152104-solved-second-variable-in-combine-string-is-ignored/ Share on other sites More sharing options...
premiso Posted April 1, 2009 Share Posted April 1, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/152104-solved-second-variable-in-combine-string-is-ignored/#findComment-798818 Share on other sites More sharing options...
bubbasheeko Posted April 1, 2009 Author Share Posted April 1, 2009 Thanks for that....I totally forgot about using htmlentities(). Quote Link to comment https://forums.phpfreaks.com/topic/152104-solved-second-variable-in-combine-string-is-ignored/#findComment-798916 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.