Jump to content


Photo

quick query question, sending emails through $row


  • Please log in to reply
8 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 August 2006 - 09:39 PM

<?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);
 }
?>
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

<?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);
?> 
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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 Buddyb3ar

Buddyb3ar
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 14 August 2006 - 10:23 PM

I'm not sure it'd be something, but the . before the = in
 $message .= "http://www.funnyemailforwards.com/apex/limitedemailresults.php";

Could cause a problem.

You could also do something like
<?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);
?>


#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 August 2006 - 10:23 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 14 August 2006 - 11:17 PM

You might try...

$to = $row['email'];


#5 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 15 August 2006 - 12:04 AM

The .= operator appends the string afterward to the string variable...i.e. :

$message .= "http://www.funnyemailforwards...."

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?

#6 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 15 August 2006 - 12:12 AM

Why are you assigning a value to $to using curly braces inside of double quotes?


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;

$to = "{$row['email']}";



#7 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 15 August 2006 - 12:16 AM

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.

#8 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 15 August 2006 - 12:21 AM

Its only really usefull when using array values within a string. ie;

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

As apposed to...


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

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

#9 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 15 August 2006 - 03:36 AM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users