What’s wrong with this wpdb query?

Try this, it worked for me: global $wpdb; $terms = $wpdb->get_col( $wpdb->prepare( “SELECT name FROM {$wpdb->terms} WHERE term_group = %d ORDER BY name ASC”, primary_tag_id )); What you are after is $wpdb->terms not $wpdb->wp_terms

Linked pages from plugin on front can’t see $wpdb

I would do something like this: <a href=”https://wordpress.stackexchange.com/questions/42287/?xp=<?php echo $row->BrExpress; ?>”> <img src=”https://wordpress.stackexchange.com/questions/42287/images/full_menu_icon.gif” alt=”See this store menu” class=”menuimg” /></a> And then to load the page when the link is clicked: function load_the_menu_page() { if(isset($_GET[‘xp’])) { global $wpdb; // retrieve database info here return $info; } } add_action(‘init’, ‘load_the_menu_page’); Note, this is just a sample. If … Read more

Insert data through a script directly in the db

Yes its possible but why go over the trouble when you can use the native functions like wp_insert_post that will take care of the interaction with the database. If you are still looking to do it directly by $wpdb then the post data is saved in the posts table, the meta data for posts is … Read more

$wpdb->num_rows doesn’t work

A few things I would do/add/change: Instead of using a query function directly I would use $wpdb->get_results Second, $wpdb->num_rows will work now. Third: setup_postdata() is what you need to actually make use of the query outside of a loop. This means get_post(get_the_ID()) doesn’t apply to anything as there is no existing $post-ID to reference. I … Read more

Fetching review value using wpdb class

You need to add the global $wpdb reference and also add the second parameter required for prepare(): global $wpdb; $post_id = $post->ID; $reviewScore = $wpdb->query( $wpdb->prepare( “SELECT review FROM {$wpdb->prefix}gdsr_data_article WHERE post_id = %d”, $post_id ) );

how to translate countries output from wp database?

you need to have the actual translations somewhere in a .mo file. for your plugin / theme. 1) when you setup the codes, you can also “mark them for translation” http://codex.wordpress.org/I18n_for_WordPress_Developers#Marking_Strings_for_Translation 2) create the translations for the languages somehow – various tools. eg this one: http://wordpress.org/extend/plugins/codestyling-localization/ 3) in your plugin must tell wp to load … Read more

wpdb->insert not inserting first variable

I don’t see anything wrong with the code as far as $first_name is concerned. My guess is that your actual DB column name is spelled incorrectly in the schema, or is otherwise improperly set up (maybe it’s the wrong type, length, etc.). This doesn’t answer your question, but I do have a tip: when a … Read more

Query the links Database

WordPress adds prefixes to tables names, which was setup on installation. So by default there is wp_ prefix for tables names. It means that by default table name for links will be wp_links. But you shouldn’t care about standard tables name, because all of them exists as parameters of wpdb class (read Table section), so … Read more

PHP variables in mysql query

To insert a new row: global $wpdb; $wpdb->insert( ‘wp_mytable’, array( ‘product’ => $product ), array( ‘%s’ ) ); For the sake of completeness, $wpdb->update is used to update an existing row and requires an additional WHERE clause, as would a “regular” SQL query. For example: global $wpdb; $wpdb->update( ‘wp_mytable’, array( ‘product’ => $product ), array( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)