Since WP3.5, prepare()
accepts placeholders as a security measure, instead of just appending the argument to the query. Therefore, $wpdb->prefix
needs to become a second parameter, called by %s
:
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM %s WHERE answer !=' '", $wpdb->prefix . "faq_questions" ) );
However, doing that returns the table name in quotes:
SELECT COUNT(id) FROM 'wp_faq_questions' WHERE answer !=' '
How can I fix this?