$wpdb->get_var returns 0

Your count for that query may be 0. Make sure $wpdb->tablex is correct. Also, definitely use $wpdb->prepare $user_followed = $wpdb->get_var( $wpdb->prepare( “SELECT COUNT( * ) AS total FROM {$wpdb->tablex} WHERE type = %d AND active = %d AND user_id = %d”, 4, 1, $user_id ) );

problem with quotes on new post

$post_content=”"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit…"”; Try encoding special characters. See: http://www.w3schools.com/tags/ref_entities.asp & http://php.net/manual/en/function.htmlentities.php

Using queries in and i see 7000+queries?

195 queries for one page is a lot. 7000 queries is not a lot, it is insane. Install Query Monitor. It tracks all queries and presents them in groups. I don’t know if it can track that many queries, this is probably an interesting stress test. 🙂 Find the source of those queries, deactivate it. … Read more

Query Concatenation

In SQL statement use placeholders instead of variable: %s (string) or %d (number). The second argument of prepare() is array of variables to substitute into the placeholders. $skill_select = $wpdb->get_results( $wpdb->prepare(” SELECT skill_name, char_id, um_id, c.class_id FROM `wp_ml_skill_class` sc JOIN `wp_ml_skill` s ON (s.skill_id = sc.skill_id) JOIN `wp_ml_character` c WHERE c.class_id = %d AND c.char_id … Read more