| | |
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 beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date decode display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip javascript joomla limit link links login mail match md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf php problem protocol query radio random recursion regex remote script search searchbox server session sessions sms smtp soap source space sql strip_tags survey syntax system table tutorial undefined update upload url validator variable video virus votedown web website window.onbeforeunload=closeme; xml youtube






