wpdb update query not working

I’ve made an email script that should update as soon as wp_mail has result. For some reason my value won’t update. Have I missed something? I am receiving the mail so the wp_mail works.

Cheers!

$email_result = wp_mail( $to, $subject, $message, $headers );

if( $email_result ){//wp_mail() processed the request successfully
    global $wpdb;
    $table_name = $wpdb->prefix . "wpsc_coupon_codes";
    $coupon_id = $ereminder->ID;

$ereminders = $wpdb->query( $wpdb->prepare("
    UPDATE *
    FROM $table_name
    SET reminder = 1
    WHERE ID = $coupon_id
") );

}

Related posts

Leave a Reply

6 comments

  1. We could use $wpdb->update, like this:

     global $wpdb;
     $table_name = $wpdb->prefix.'your_table_name';
     $data_update = array('row_name_1' => $row_data_1 ,'row_name_2' => $row_data_2);
     $data_where = array('row_name' => $row_data);
     $wpdb->update($table_name , $data_update, $data_where);
    
  2. You may change instead of (UPDATE * FROM)

    $ereminders = $wpdb->query($wpdb->prepare("UPDATE $table_name SET reminer='1' WHERE ID=$coupon_id"));
    

    and use no break.

    Thank you.

  3. Example of mine that is working:

    $result = $wpdb->update(
        $wpdb->prefix .'sae_calendar', 
        array( 
            'year' => $year,
            'quarter' => $quarter,
            'start_date' => $start_date,
            'end_date' => $end_date,
            'reservation_start_date' => $reservation_start_date,
            'reservation_end_date' => $reservation_end_date 
        ), 
        array(
            "id" => $id
        ) 
    );
    
  4. <?php 
      global $wpdb;
        if(isset($_POST['progress'])){
        $table=t_test;
        $data=array('client_development'=>$_POST['Progress']);
        $where=array('p_id'=>$_SESSION['id']);
        $format=("%d");
        $whereFormat=("%d");
        $result4=$wpdb->UPDATE($table,$data,$where,$format,$whereFormat);
      }
    ?>
    <form method="post">
      <input type="text" name="Progress">
      <input type="submit" name="progress" value="Prog%">
    </form>
    <?php 
    if(isset($_POST['progress'])){
    $table=t_test;
        $data=array('client_development'=>$_POST['Progress']);
        $where=array('p_id'=>$_SESSION['id']);
        $format=("%d");
        $whereFormat=("%d");
        $result4=$wpdb->UPDATE($table,$data,$where,$format,$whereFormat);
    }
    ?>
    <form method="post">
      <input type="text" name="Progress">
      <input type="submit" name="progress" value="Prog%">
    </form>