get_var is neither a string, integer, or array …?
var_dump($vote_count) should tell you what type $vote_count is. Probably you’re getting NULL.
var_dump($vote_count) should tell you what type $vote_count is. Probably you’re getting NULL.
You can filter ‘posts_fields’, check if it is the main query and limit the queried fields to … whatever you need. See WP_Query::get_posts() in /wp-includes/query.php for details and side effects. For debugging the queries I recommend the plugin Debug Bar. If you add … define( ‘WP_DEBUG’, TRUE ); define( ‘SAVEQUERIES’, TRUE ); … to your … Read more
You should not use mysql_fetch_array() Use wordpress built-in functions, like this: $SQL = “SELECT * FROM pt_country ORDER BY name”; $rows = $wpdb->get_results( $SQL ); foreach($rows as $r){ print_r($r); }
The requirements you’ve specified don’t indicate any need for a custom post table. Just register a custom post type using register_post_type(), and then manipulate its entries using the standard WordPress API. Example from the codex, registering a ‘book’ custom post type with a label of “Books”: function my_init() { $args = array( ‘public’ => true, … Read more
Haven’t tested it, but this should work: SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->terms.name, wpcflat.meta_value AS latitude, wpcflong.meta_value AS longitude, 6371 * 2 * ASIN ( SQRT (POWER(SIN(($lat – wpcflat.meta_value)*pi()/180 / 2),2) + COS($lat * pi()/180) * COS(wpcflat.meta_value *pi()/180) * POWER(SIN(($long – wpcflong.meta_value) *pi()/180 / 2), 2) ) ) AS distance, wpcfthumbnail AS thumbnail_id; FROM $wpdb->posts LEFT JOIN … Read more
OP found the solution: Problem solved, found spaces in the array $arrname. I’m posting as a brief answer to tidy up our site. If anyone would like to up vote it to get the question closed then that would be great 🙂 Alternatively, express your view on the quality of question.
Your code of wpdb method is correct. posible reasons why it fails… you have only one user that match’s meta_key = ‘user_token’ other functionality change query at query hook filter strage. debug the final SQL with add_filter( ‘query’, ‘query_report’, 10000 ); function query_report($sql){ var_dump($sql); return $sql; }
its normal for get_results method you can use get_row method to get only one row.
Your specific issue in that code is that you’re missing the quote marks around the $code. $query .= ‘WHERE code=”.$code; Should be: $query .= “WHERE code= “‘.$code.'”‘; In the long run, you should indeed use prepare() properly, but this is the specific problem with the code you posted.
Because you’re missing second argument, for more information see this post – http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/. Also you’re doing it wrong, for security reason you shouldn’t pass variables into query directly that’s why you should use prepare() method – see Codex for usage info.