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
$vote_count = $wpdb->get_var($wpdb->prepare("SELECT votes FROM wp_mytable WHERE product = %s AND
                              company = %s", $product, $company));
            $html = '<a href="#" class="vote_for_doc">
            Vote here</a> (<span class="vote-count">' . $vote_count . '</span> Votes for ' . $product . ' and ' . $company . ')';
                $html = '$vote_count is a string in the database<p>' . print_r($vote_count);
                $html = '$vote_count is an array in the database<p>' . print_r($vote_count);
                $html = '$vote_count is not a string or an integer<p>' . print_r($vote_count);

And my output:

$vote_count is not a string or an integer


share|improve this question
up vote 1 down vote accepted

var_dump($vote_count) should tell you what type $vote_count is. Probably you're getting NULL.

share|improve this answer
Yes, it's NULL. Why would I get NULL if it returns '1'? – AlxVallejo Jun 12 '12 at 16:16
Oh I see, I just switched from get_var to get_results and it worked. – AlxVallejo Jun 12 '12 at 16:26

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.