Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
$vote_count = $wpdb->get_var($wpdb->prepare("SELECT votes FROM wp_mytable WHERE product = %s AND
                              company = %s", $product, $company));
        if(is_int($vote_count)){
            $html = '<a href="#" class="vote_for_doc">
            Vote here</a> (<span class="vote-count">' . $vote_count . '</span> Votes for ' . $product . ' and ' . $company . ')';
        }else{
            if(is_string($vote_count)){
                $html = '$vote_count is a string in the database<p>' . print_r($vote_count);
            }if(is_array($vote_count)){
                $html = '$vote_count is an array in the database<p>' . print_r($vote_count);
            }else{
                $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

1

share|improve this question
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.