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

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -