Jump to content

Archived

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

Ninjakreborn

quick query question, sending emails through $row

Recommended Posts

[code]
<?php
while ($row = mysql_fetch_array($emailquery)) {
 $to = "{$row[email]}";
 $subject = "Funny Email Forwards Database Results";
 $message = "You can see the results at this page: ";
 $message .= "http://www.funnyemailforwards.com/apex/limitedemailresults.php";
 echo "<br />";
 echo "{$row[email]}";
 echo "<br />";
 //mail($to, $subject, $message);
}
?>
[/code]
That is the script I am using to debug, it prints out all the emails, but when I cut it down and use my original script

[code]
<?php
while ($row = mysql_fetch_array($emailquery)) {
 $to = "{$row[email]}";
 $subject = "Funny Email Forwards Database Results";
 $message = "You can see the results at this page: ";
 $message .= "http://www.funnyemailforwards.com/apex/limitedemailresults.php";
 mail($to, $subject, $message);
?>
[/code]
It's not seeming to email them, I know this, because my email is in the database too, but it's not sending me an eamil, so I am guessing the others aren't either, adn I can't keep testing them and sending them emails over and over again, is there anythign wrong with this.

Share this post


Link to post
Share on other sites
I'm not sure it'd be something, but the . before the = in
[code]
$message .= "http://www.funnyemailforwards.com/apex/limitedemailresults.php";
[/code]
Could cause a problem.

You could also do something like
[code]
<?php
while ($row = mysql_fetch_array($emailquery)) {
  $to = "{$row[email]}";
  $subject = "Funny Email Forwards Database Results";

$message = array();
  $message[] = "You can see the results at this page: ";
  $message[] = "http://www.funnyemailforwards.com/apex/limitedemailresults.php";

  mail($to, $subject, $message);
?>
[/code]

Share this post


Link to post
Share on other sites
It shouldn't be the . should it, I always did message like that, but I also never send an email through a query like that either, I will play with that, thanks.

Share this post


Link to post
Share on other sites
You might try...

[code=php:0]
$to = $row['email'];
[/code]

Share this post


Link to post
Share on other sites
The .= operator appends the string afterward to the string variable...i.e. :

[code]$message .= "http://www.funnyemailforwards...."[/code]

Will append the http://....... to whatever $message previously was.

That is not your problem.

Thorpe probably has it right.  Why are you assigning a value to $to using curly braces inside of double quotes?

Share this post


Link to post
Share on other sites
[quote]Why are you assigning a value to $to using curly braces inside of double quotes?[/quote]

It would be perfectly valid (if still a little unnesessary) if he'd used quotes around the array key like your meant to when refering to non numerical keys. eg;

[code=php:0]
$to = "{$row['email']}";
[/code]

Share this post


Link to post
Share on other sites
Had to look that up...not because I don't believe you, cause I wanted to see how it's done...never used it that way...I've always done it the way you suggested.

Share this post


Link to post
Share on other sites
Its only really usefull when using array values within a string. ie;

[code=php:0]
$arr = array('name' => 'foo');
echo "Hello {$arr['name']}, how you doing?";
[/code]

As apposed to...


[code=php:0]
$arr = array('name' => 'foo');
echo "Hello ". $arr['name']. ", how you doing?";
[/code]

Of course php is pretty forgiving with regard to quotes around array keys anyway, but that, IMO is a design floor.

Share this post


Link to post
Share on other sites
Thats the thing, I reallized my client was getting the proper email, he is on the list, of subscribers, plus he got his admin email at his other address, so I am assuming it is emailing some and missing some, quite confusing.

Share this post


Link to post
Share on other sites

×

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.