| | |
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 beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube






