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.
Link to comment
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]
Link to comment
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?
Link to comment
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]

Link to comment
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.
Link to comment
Share on other sites

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.