Forums

wpdb doesn't work for me (1 post)

  1. tsov
    Member
    Posted 8 months ago #

    Hey guys!

    I have been looking all over for an answer to a probably simple question. I hope i can find help over here.

    global $wpdb;
    
    $table_name = $wpdb->prefix . "newsletter_subs";
    $results = $wpdb->get_results( "SELECT * FROM " . $table_name , );
    
    foreach ( $results as $res ) {
    	$id = $res->id;
    	$to = $res->email;
    
    	if(mail($to, $subject, $message, $from)) {
    		echo("<p>Message delivery successful: <strong>" . $id . " " . $to . "</strong></p>");
    	}
    
    	else {
    		echo("<p>Message delivery failed: <strong>" . $id . " " . $to . "</strong></p>");
    	}
    }

    What is wrong? I just don't get it to work.

    Thank you!

Reply

You must log in to post.

About this Topic

Tags