| | |
send email on mysql db update
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
i am trying to get this code to work but there is something wrong with the array (not to good at these). the main part of the code works it is sending out the email but only ever to one registered user.
here is the code i have so far.
here is the code i have so far.
PHP Syntax (Toggle Plain Text)
$query = "SELECT email FROM emails"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $contactemail = $row['email']; // Contacts //$replyName = $merc_replyId; //$replyEmail = $merc_replyAddress; $replyName = "PiPonliine"; $replyEmail = "info@piponline.info"; $contactname = ""; // Subject $subject = "Website Update"; // Headers $headers = "MIME-Version: 1.0" . PHP_EOL; $headers .= "Content-type: text/html; charset=iso-8859-1" . PHP_EOL; $headers .= "From: ".$replyName." <".$replyEmail.">" . PHP_EOL; $headers .= "BCC: ".$contactname." <".$contactemail.">\r\n" . PHP_EOL; mail($contactemail, $subject, $message, $headers); } echo "$contactemail"; echo "<h2>Email notification sent</h2>"; echo "<h2>1 record added</h2>"; mysql_close($con);
•
•
Join Date: Feb 2009
Posts: 83
Reputation:
Solved Threads: 7
[QUOTE=kevin wood;821441]i am trying to get this code to work but there is something wrong with the array (not to good at these). the main part of the code works it is sending out the email but only ever to one registered user.
Hi..
i dont know the exact solution....but, try to do this...
1) if there is any id in database, try to using id by incrementing.......
2) try to use FOREACH instead of while......
this is just try, i dont know the exact way.....
Hi..
i dont know the exact solution....but, try to do this...
1) if there is any id in database, try to using id by incrementing.......
2) try to use FOREACH instead of while......
this is just try, i dont know the exact way.....
@Kevin wood, Your script seems fine.
Try this.
This definitely works. (I tried with 3 email addresses)
Try this.
php Syntax (Toggle Plain Text)
$query = "SELECT email FROM emails"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $emailaddress[] = $row['email']; } // Contacts //$replyName = $merc_replyId; //$replyEmail = $merc_replyAddress; $i=0; foreach($emailaddress as $contactemail) { $replyName = "PiPonliine"; $replyEmail = "info@piponline.info"; $contactname = ""; // Subject $subject = "Website Update"; // Headers $headers = "MIME-Version: 1.0" . PHP_EOL; $headers .= "Content-type: text/html; charset=iso-8859-1" . PHP_EOL; $headers .= "From: ".$replyName." <".$replyEmail.">" . PHP_EOL; $headers .= "BCC: ".$contactname." <".$contactemail.">\r\n" . PHP_EOL; mail($contactemail, $subject, $message, $headers); $i++; } echo "$contactemail"; //this will print only 1 email address, which is the last one echo "<h2>Email notification sent</h2>"; echo "<h2>".$i." mails sent</h2>";
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- send email on mysql db update (PHP)
- Using PHP/HTML to update informationin MySQL (PHP)
- Need Developer: mysql and associated pages (Web Development Job Offers)
- How to pre-select checkboxes in form? (PHP)
Other Threads in the PHP Forum
- Previous Thread: IP Penguin Shower
- Next Thread: Resize Image + retain quality + upload to mysql database
| Thread Tools | Search this Thread |
apache api array back basic beginner binary broken cakephp checkbox class cms code computing confirm cron curl customizableitems database date delete display dynamic echo email error external file files filter folder form forms forum function functions gc_maxlifetime google headmethod host href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php problem query question radio random recursion regex remote script search server sessions sms snippet soap source space sql syntax system table thesishelp trouble tutorial update upload url validator variable video web xml youtube






