| | |
send email on mysql db update
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
i am trying to write a script that will send out an email to all the email addresses stored in a mysql db when the site has been updated. the code i have so far is as follows
this code is giving me the following error message which as far as i know means that array is not being populated.
due to the error the emails are not being sent even if the code for that section is correct or not.
PHP Syntax (Toggle Plain Text)
$sql= "INSERT INTO $table (date, title, article) VALUES ('$a', '$b', '$c')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } $lastid = mysql_insert_id(); $message .= '<body leftmargin="0" topmargin="0"> <table width="700" border="0" align="center" cellpadding="0" cellspacing="5"> <tr> <td>The ' . $table . ' section of the <a href="piponline.info"> PiPonline website</a> has been updated. Please follow the link to see the new content. </tr> </table> </body>'; $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.">\r\n" . PHP_EOL; $headers .= "BCC: ".$contactname." <".$contactemail.">\r\n" . PHP_EOL; mail(implode(',', $contactemail), $subject, $message, $headers); echo "$contactemail"; echo "<h2>Email notification sent</h2>"; echo "<h2>1 record added</h2>"; mysql_close($con);
this code is giving me the following error message which as far as i know means that array is not being populated.
PHP Syntax (Toggle Plain Text)
Warning: implode(): Bad arguments
due to the error the emails are not being sent even if the code for that section is correct or not.
Last edited by kevin wood; Mar 6th, 2009 at 7:47 am.
i have changed the code slightly now and have got it sending out one email. i have narrowed the problem down to the mysql query as this is not populating the array it is only putting on email address in.
here is the code for the mysql statement
here is the code for the mysql statement
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[0]. ", "; }
![]() |
Similar Threads
- Using PHP/HTML to update informationin MySQL (PHP)
- Confused with reading Microsoft White Papers and Instructions (ASP)
- How can I set up an email system? (PHP)
- Permanent Server Process (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: Validating input?
- Next Thread: display of currency exchange rates
Views: 982 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl customizableitems database date development directory display download dynamic echo email error file files folder form forms forum function functions google headmethod href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail malfunctioning menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






