php - Why this SQL query not working -


i have bits code postmeta (wordpress) $wpdb method, don't know why code not working.

global $wpdb;  $meta_key   = "'_bbp_vs_name_1', '_bbp_vs_name_2'"; $tags_query = "po"; $query      = $wpdb->esc_like( $tags_query ); $value      = '%' . $query . '%';  $ajax_teams = $wpdb->get_results( $wpdb->prepare( "     select *     $wpdb->postmeta     meta_key in ( $meta_key )     , meta_value %s     ",     $meta_key,     $value ) );  print_r( $ajax_teams ); 

please help.

working solutions:

$ajax_teams = $wpdb->get_results( $wpdb->prepare( "     select *     $wpdb->postmeta     meta_key in ( $meta_key )      , meta_value %s     ",     $value ) ); 

you need bind %s in query. have given varible direction

$ajax_teams = $wpdb->get_results( $wpdb->prepare( "     select *     $wpdb->postmeta     meta_key in ( %s )      , meta_value %s     ",     $meta_key,     $value ) ); 

also change value :

$value      = "'%".$query."%'"; 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -