WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been at this for while, but can't figure out why the below isn't working. I have my date saved as a 'MM/DD/YYYY' string.

global $wpdb;
$new_day = $day->format("m/d/Y");
$qty = $wpdb->get_var( $wpdb->prepare( 
    SELECT qty
    FROM $wpdb->specials
    WHERE date = %s
share|improve this question
Where does $day->format("m/d/Y"); come from as it isn't shown as global. – kaiser Apr 11 '12 at 9:57

I'll guess that $wpdb->specials isn't giving you what you expect. custom tables have to referenced like $wpdb->prefix . 'specials'

share|improve this answer
thanks Milo. found that because it a custom table, you dont need the $wpdb at all. – Aaron Moodie Apr 11 '12 at 4:36
@AaronMoodie you don't, however if the table prefix set in wp-config.php may ever change, you'll want to have that in there. – Milo Apr 11 '12 at 8:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.