I'm trying to use the $wpdb-query method, but can't seem to get it to work.
I get a 500 error when I try the following:
$update_status = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}wcpv_commissions SET commission_status = '".$status."' WHERE vendor_id = '".$vendor_id."' AND order_date BETWEEN '".$date1."' AND '".$date2."'"));
Is there something I am missing here. I have not used $wpdb much, so am sure I must be missing something.
I appreciate any help here.
Thanks!
I'm trying to use the $wpdb-query method, but can't seem to get it to work.
I get a 500 error when I try the following:
$update_status = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}wcpv_commissions SET commission_status = '".$status."' WHERE vendor_id = '".$vendor_id."' AND order_date BETWEEN '".$date1."' AND '".$date2."'"));
Is there something I am missing here. I have not used $wpdb much, so am sure I must be missing something.
I appreciate any help here.
Thanks!
Without an error message, it is difficult to tell the exact problem. It is important to debug within WordPress and check your webserver error logs.
One problem is your call of prepare()
. The method takes 2 or more arguments, you only passed 1. Instead try the following
$update_status = $wpdb->query($wpdb->prepare(
"UPDATE {$wpdb->prefix}wcpv_commissions SET commission_status = %s WHERE vendor_id = %d AND order_date BETWEEN %s AND %s",
$status,
$vendor_id,
$date1,
$date2
));
prepare
properly. If you enable debugging you will likely see an error message. – Milo Commented Dec 12, 2018 at 23:44