| | |
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
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web websphere white xml youtube






