wpdb->get_var always returning 0

prepare accepts three placeholder arguments— ” %s (string), %d (integer) and %f (float)”. You have used %i. That isn’t going to get through the sanitization process. That is why you are getting 0. You need %d instead.

error code: 523