wpdb query not working

It’s probably because you must use % sign for “like” so it would be: SELECT * FROM `wp_usermeta` WHERE meta_key= ‘referrer’ AND meta_value LIKE ‘%270%’ AND meta_key= ‘view_type’ AND meta_value LIKE ‘%invoice%’

WPDB Join with custom table

I think you need to distinguish which table your ID and post_id come from. Take a look below and notice how the tables get a variable assigned. You could also just use the table name, but this reads easier. SELECT P.post_id FROM [prefix]_calp_events as EV JOIN [prefix]_posts as P ON EV.ID = P.post_id You stated … Read more

$wpdb query outputs php code instead of executing it

It’s very clear that your file is not executing PHP functions, and the problem probably is because you are saving this file as something.html, storing it inside your theme or WordPress installation directory. What you can do, is to wrap this as a function or shortcode, and then create a page and use that shortcode … Read more

$wpdb->insert() doesnt work anymore

examine below example and figure out what is wrong with your code. global $wpdb; if(isset($_POST[‘submit’])) { $table_name = $wpdb->prefix.’employee’; $wpdb->insert( $table_name, array( ‘first_name’=>$fname, ‘last_name’=>$lname), array( ‘%s’,’%s’ ) ); use global $wpdb; global $wpdb; $table_name = $wpdb->prefix.’rdp_banners’; $wpdb->insert( $table_name, array( ‘banner_id’ => $banner_id, ‘rdp_banner’ => $rdp_banner, ‘banner_type’ => $banner_type, ‘customer_id’ => $customer_id, ‘status’ => $status, ‘company_name’ … Read more

Need help converting get_user_meta [keys] into own array

You have to return the keys from array with this: $keys = array_keys($all_meta_for_user); Afterwards, implode your array to a string (inserting a dot before to create the first class): $stringedKeys=”.”.implode(‘,.’, $keys); And now you have a string of keys that you can use in JS if you like, or insert them from PHP directly.

Get unique results from this function

It would likely be more efficient to change your database query to SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = ‘wc_billing_field_3465’

how to connect to another database in wordpress

Look at the order of the constructor arguments in the documentation: string $dbuser, string $dbpassword, string $dbname, string $dbhost You’ve got the arguments in the wrong order. Move the host to the end: $newconnection= new wpdb(“username”,”password”,”databasename”,”localhost”);

WP-PostRatings: list current user’s rated posts

Plugin questions are best asked on the plugin’s support forum. But this code is wrong: $result = $wpdb->get_results($sql) or die(mysql_error()); foreach( $results as $result ) { echo $result->name; } The foreach is backwards. Go for this (corrected $result to $results in the first line – added ‘s’): $results = $wpdb->get_results($sql) or die(mysql_error()); foreach( $results as … Read more

Display category names on edit user profile using $wpdb

The $wpdb->query() method doesn’t return query results but a count on how many rows were affected by the query. To get the results you have to user the $wpdb->get_results($sqlString) method and then iterate over it. <?php function custom_user_profile_fields($profileuser) { ?> <h1>Select a Category</h1> <select name=”category”> <?php global $wpdb; $terms = $wpdb->get_results( “SELECT name FROM wp_terms” … Read more

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