Jump to content

quick query question, sending emails through $row


Ninjakreborn

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.
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]
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?
[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]

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

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.