• Hello guys,

    I am having trouble with getting wordpress to send a pre-defined message, stored in database. I would like to use wysija newsletter plugin to be able to modify the email template and keep inline css without having to bother about it.

    Here is part of my code, retrieved by a cron job:

    global $wpdb;
    $results = $wpdb->get_results( $wpdb->prepare( “SELECT body FROM wysija_email WHERE email_id === 7”) );
    $message = $results;
    // $message = ‘This is a test message.’;
    $email_result = wp_mail( $to, $subject, $message, $headers );

    When I remove the slashes, the testmessage sends successfully, but I can not manage to send the message stored in the database. I also tried changing body to created_at (which is just a simple number) to see whether the field was too large or inconsistent, but it doesn’t look like it is the case. What am I doing wrong?

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    One problem is email_id === 7. This is for a mySQL statement, the SQL equivalence operator is simply =. === is a PHP operator and is not recognized by mySQL.

    FYI, you can double check SQL queries in phpMyAdmin, usually accessed through your hosting cPanel. Pick the correct DB, then go to the SQL tab where you can enter a statement and execute it. Be very careful executing queries that change the DB, make a complete backup first. It’s very easy to completely foul up your DB using this app.

Viewing 1 replies (of 1 total)

The topic ‘Sending a pre-defined message stored in database’ is closed to new replies.