php - wpdb->prepare() returns NULL -


i can't figure out why returning "null". i've hardcoded date/time string in $scheduleddates variable. in practice that's user input. works fine when don't prepare query.

$scheduleddate = "2015-09-01 00:00:00";  $querystring = "select * schedules event_start > %s , event_start < %s + interval 1 day";  $scheduled_blocks = $wpdb->get_results( $wpdb->prepare( $querystring, $scheduleddate ) ); 

the code below works fine, whether hard code date/time or not...

$scheduleddate = $_post['scheduleddate'];  $scheduled_blocks = $wpdb->get_results('select * schedules event_start > "' . $scheduleddate . '" , event_start < "' . $scheduleddate . '" + interval 1 day'); 

use $wpdb->print_error() see errors get. of code though, think number of placeholders have same amount of values you're supplying prepare method. alter call this:

$wpdb->prepare($querystring, $scheduleddate, $scheduleddate) 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -