$wpdb update query in plugin only updating one column

I had to use two separate queries. The $wpdb->update syntax cant deal with calculating based on the existing value. But for the other two fields it works. So like this: $table = $wpdb->prefix . ‘woocommerce_downloadable_product_permissions’; $expiry_date = date(“Y-m-d”, strtotime(“+ 30 days”)); $expiry_time = $expiry_date . ‘ 00:00:00’; $wpdb->query(“UPDATE $table SET download_count = (download_count + 1) … Read more

How to retrieve the data from the sever and displaying it in a page?

So in this case, the problem is that your line right before the echo call is incomplete: $number_rows= $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->daviddgl_wp1.SaveContactForm7_7” ); $x=1; while ($x<$number_rows) { $results = $wpdb->get_results(“SELECT ticket, name,email FROM $wpdb->daviddgl_wp1.SaveContactForm7_7 WHERE id = $x”); print_r($results); $x++; } (You’re missing the closing bracket and semi-column) Note also that your echo will … Read more

Getting variable from Database

Prepend the table prefix to iyzico_order_refunds instead of the $wpdb object: $payment_transaction_id = $wpdb->get_var( “SELECT payment_transaction_id FROM {$wpdb->prefix}iyzico_order_refunds} WHERE order_id=769 AND item_id=760” );

Make a SQL query with wpdb in WordPress

The main problem is how you’re specifying the custom table name (e.g., $wpdb->cf7dbplugin_submits). $wpdb only knows about the “built-in” tables when accessing a table name via $wpdb->xxx. To specify access a custom table name, use {$wpdb->prefix}custom_table_name. The other thing I notice is that, for security purposes, you should never use interpolated variables in an SQL … Read more

Error using WordPress $wpdb object to get result from custom table

I have checked your code and I think there are the couple of things you have to consider: table prefix column name validate get_results function output Firstly, the original prefix is defined in wp-config.php. The WordPress $wpdb class provides a variable $prefix. Always use $wpdb obefore table name and it will automatcially insert the table … Read more

Getting All Post From Specific category in wpdb

Well, there are many things that are not exactly correct with your code: $posts = $wpdb->get_results( “SELECT ID, post_title, post_modified_gmt FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships as t ON ID = t.object_id WHERE post_type=”post” AND post_status=”publish” AND t.term_taxonomy_id = 3 WHERE post_status=”publish” # <– !! second WHERE clause AND post_password = ” AND post_type=”post” # <– … Read more

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