admin管理员组文章数量:1130349
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!
Share Improve this question edited Dec 12, 2018 at 23:45 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Dec 12, 2018 at 23:34 TaphaTapha 1034 bronze badges 3 |1 Answer
Reset to default 4Without 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
));
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!
Share Improve this question edited Dec 12, 2018 at 23:45 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Dec 12, 2018 at 23:34 TaphaTapha 1034 bronze badges 3-
Have a look at the documentation for how to use
prepareproperly. If you enable debugging you will likely see an error message. – Milo Commented Dec 12, 2018 at 23:44 - Where are you running this code? It's difficult to tell what could be wrong when you've shown a single line, can you provide more code context? E.g. it could be related to global variables but without seeing more context it's impossible to tell. It could also be that you're trying to call it in a standalone file you're loading directly, but again, impossible to tell with the information available. Also, what are you trying to do? Something involving commissions – Tom J Nowell ♦ Commented Dec 13, 2018 at 0:00
- Also, 500 error is just the servers way of saying something went wrong in PHP, we don't know what it was, check the PHP error log for the real error message. Can you look up your PHP error log to find that error message? – Tom J Nowell ♦ Commented Dec 13, 2018 at 0:02
1 Answer
Reset to default 4Without 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
));
本文标签: I can39t figure out what39s wrong with this statement wpdbgtquery update
版权声明:本文标题:I can't figure out what's wrong with this statement. $wpdb->query update 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749104185a2316477.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


prepareproperly. If you enable debugging you will likely see an error message. – Milo Commented Dec 12, 2018 at 23:44