Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php mailing script - convert from mysql to odbc for access

    im working on a modifying a mailing list that i found, that will allow me to send email to certain addresses located in a access database.

    I dont get any error, but I am not receiving the email. i setup myself in the database, residing in a state that no one else is from, so i can test mail to myself.


    heres the code:

    PHP Code:
    <?php

    include("dbconnection.php");
    if (!isset(
    $_POST['submit'])):

    ?>
    <html>
    <head>
    </head>
    <body>

    <?php require_once("adminOnly.php");?>

    //theres more html here, but no need to paste it in

    </body>
    </html>


    <?php else:

    ini_set(SMTP"mail.sliquid.com");
        
    ini_set(smtp_port25);
        
    ini_set(sendmail_from"info@sliquid.com");

      
    $to $_POST['to'];
      
    $subject $_POST['subject'];
      
    $message $_POST['message'];
      
    $state $_POST['state'];

      if (
    "all" == $to) {
       
    $x 1;
       
    $hold 50// quantity of emails sent before 3 sec delay
       
    $emails ="SELECT email FROM customers";

       while (
    $sendemail odbc_exec($cnx,$emails)) {
       
    $email $sendemail["email"];
       
    mail($email$subject$message"From:Sliquid Email List <info@sliquid.com>");
       

       
    $x++;
        if(
    $x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
        
    sleep(3);
        
    $x 0;
        }
       } 
    // end of while loop
      


    else {
       
    $bycountry ="SELECT email FROM customers WHERE state = '$state'";
       while (
    $statemail odbc_exec($cnx,$bycountry)) {
       
    $email $statemail["email"];
       
    $okemail mail($email$subject$message"From:Sliquid Email List <info@sliquid.com>");

       
    $x++;
        if(
    $x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
        
    sleep(3);
        
    $x 0;
        }
       } 
    // end of while loop
      
    }

    ?>
    <html>
    <head>
    </head>
    <body>

    SUCCESS! You will be redirected.
    <?php
    header
    ("Refresh: 3; URL=http://www.sliquid.com/protected/admin.php");
    echo 
    " "// NN4 requires that we output something...
    exit();
    ?>

    </body>
    </html>
    <?php endif; ?>
    also, heres my dbconnection.php

    PHP Code:
    <?php
    $cnx 
    odbc_connect'records_db' 'Admin''******' );
        if (!
    $cnx) {
            
    Error_handler"Error in odbc_connect" $cnx );
        }
    ?>
    also, the ini_set stuff is from another page i have that emails properly, but i dont know if i need it for this script.

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,092
    Thanks
    2
    Thanked 23 Times in 23 Posts
    I'd put some echo statements in the code to see if the script is even executing at certain spots. For example:

    Code:
       $emails ="SELECT email FROM customers";
    echo "emails = ". $emails . "<br><br>"; 
    
       while ($sendemail = odbc_exec($cnx,$emails)) { 
       $email = $sendemail["email"];
    echo "email = " . $email . "<br><br>"; 
    echo "subject = " . $subject . "<br><br>"; 
    echo "message = " . $message . "<br><br>"; 
       mail($email, $subject, $message, "From:Sliquid Email List <info@sliquid.com>");
    That should tell you where things might be going wrong.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    New Coder
    Join Date
    Jan 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, I'll give it a try and report back

  • #4
    New Coder
    Join Date
    Jan 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i had to change some things to make it display, but here we go.

    PHP Code:
    else {
     $bycountry ="SELECT email FROM customers WHERE state = '$state'";
    echo "bycountry = ". $bycountry . "<br><br>";
    // $bycountry = "colin@sliquid.com";
       while ($statemail = odbc_exec($cnx,$bycountry)) {
       $email = $statemail["email"];
    echo "email = " . $email . "<br><br>"; 
    echo "subject = " . $subject . "<br><br>"; 
    echo "message = " . $message . "<br><br>";
        $headers2 = "From: info@sliquid.com\r\n";
        $headers2 .= "BCC: sales@sliquid.com\r\n";
      // $okemail = mail($email, $subject, $message, $headers2);

       $x++;
        if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
        sleep(3);
        $x = 0;
        }
       } // end of while loop
      }

    ?>
    <html>
    <head>
    </head>
    <body>
    SUCCESS! You will be redirected.
    <?php
    header
    ("Refresh: 3; URL=http://www.sliquid.com/protected/admin.php");
    echo 
    " "// NN4 requires that we output something...
    exit();
    ?>
    </body>
    </html>
    <?php endif; ?>
    when i submit, i get this
    bycountry = SELECT email FROM customers WHERE state = 'Vermont'

    email =

    subject = Subject - Test

    message = testing 123 this is a test testing 123


    then this repeats over and over, 50 times

    email =

    subject = Subject - Test

    message = testing 123 this is a test testing 123

    email =

    subject = Subject - Test

    message = testing 123 this is a test testing 123

    etc....


    so its seeing my SQL request as text.
    what is wrong with the syntax?

  • #5
    New Coder
    Join Date
    Jan 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone?
    Last edited by croix; 01-05-2006 at 04:15 PM.

  • #6
    New Coder
    Join Date
    Jan 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i think separating the sql from teh mail will help. how should i do this, without moving my query to my include page?


  •  

    Posting Permissions

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