Problem displaying inserted form

In your code I encountered two problems. First one is you have not defined $current_user and $abcde variable. For using global $current_user you need to define it in the top of the function as global $current_user. Otherwise it will not get the $current_user variable. And also for getting the current user ID yo need to … Read more

WP Sql query multiple where clause

You can try this with WP_User_Query instead: $args = array ( ‘meta_query’ => array( array( ‘key’ => ‘newsletter’, ‘value’ => ‘true’, ), array( ‘key’ => ‘account’, ‘value’ => ‘false’, ), ), ‘date_query’ => array( array( ‘after’ => ‘2015-01-13 00:00:00’, ‘inclusive’ => true, ), ), ); $user_query = new WP_User_Query( $args ); where I assume your … Read more

How does the WXR file differ from the WPDB?

There’s not a one-to-one relationship between the WordPress database and the .wxr file. We can find this line in the exported .wxr file: <!– This file is not intended to serve as a complete backup of your site. –> Skimming through the export_wp() function, we can see what’s excluded, for example: The data stored in … Read more

Fixing wpdb->get_results and wpdb->prepare?

As per suggestion by Milo, I removed the prepare statement, and it worked beautifully: $rs = $wpdb->get_results( “SELECT id, title, alias FROM $rs_table_name ORDER BY id ASC LIMIT 999” ); I then came to try and overwrite it through a child theme. It was being added to a filter originally in the parent theme: add_filter( … Read more

$wpdb->get_results returns empty but value exists

It is hard to say without hands on access to your data. Either the query is actually failing or the query is not something you expect in that context. You should enable error reporting via $wpdb->show_errors( true ) before it and check $wpdb->last_query for sanity after.

How can I migrate mysql_fetch_array to $wbpdb?

You didn’t need to post all that code to wade through! The problem is here: <?php global $wpdb; function get_tag_data2() { You need to global inside the function – that’s the point of global: <?php function get_tag_data2() { global $wpdb; // Original function code }

$wpdb->insert query changes to SHOW COLUMNS query Output

For anyone else finding this question. WordPress seems to do a SHOW FULL COLUMNS query before executing the INSERT query. If it determines that the INSERT query would fail/store bad data, for example because the given data types would not fit in the column, it does not execute the insert query at all and return … Read more

WPDB Update using Conditional Arrays

This is not posible with $wpdb->update(). If you check the source code, you will see these lines (lines 2150 – 2161), there is no way getting an OR in there: foreach ( $where as $field => $value ) { if ( is_null( $value[‘value’] ) ) { $conditions[] = “`$field` IS NULL”; continue; } $conditions[] = … Read more

Using WPDB class

You can’t mix wpdb with mysql_fetch_array. They are not compatible. You need to use wpdb methods, plus PHP functions like while, foreach, and for. wpdb does not return the references that PHP’s mysql functions use. It returns an object, and array, or sometimes a string. In your case, though, the database part is done. You … Read more

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