SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2004
    Location
    colorado Springs
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Sending an email on insert in MySql? Can it be done

    Can someone provide me with code that will send an email to inform someone when a record is inserted into a MySql db. thanks.

  2. #2
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure!

    PHP Code:
    //var to hold query:
    $sql "SELECT fields FROM table";
    //var to execute query:
    $query mysql_query($sql):

    //if query is not successful..
    if(!$query)
    {
         
    //display error
         
    echo mysql_error();
    }
    //if it is
    else
    {
         
    //send an email
         
    mail('mail@to.com''subject''message''additional headers');

    Good luck. Might want to look at www.php.net/mail for more about sending email through PHP.
    SK


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •