How do I update post based on meta_key in another table?

I couldn’t comment, because i dont have the rep Your code will not update because meta_key field is not in the wp_post table. First, you’ll want to query all posts where the meta_key wpcf-engine-days-to-go = 0 and then iterate through the post ID’s and make your changes to the wp_posts. Un-tested Example: $meta_value = 0; … Read more

WPDP related functions look to work but they don’t

Formalizing comment answer here: Based on the code you provided the problem is possibly that you are using literal strings rather than interpolated values in your SQL. There’s a big difference between backticks ` and single-quotes ‘. try this: $retArray = $wpdb->get_row(“SELECT * FROM {$wpdb->prefix}wcpl_user_packages WHERE DATEDIFF(NOW(), package_timestamp) >= package_dduration AND id = {$package->id} AND … Read more

get_row returns empty when data exists

You have several things going on there and I may not be able to sort them all out. Unless $wpdb->cf7dbplugin_submits has been added to the $wpdb object your query won’t work. You will need something like {$wpdb->prefix}cf7dbplugin_submits instead but I can’t really guess at the right value. You don’t need to swap in 9999. That … Read more

Why is an empty result an error? ( $wpdb->get_row )

There isn’t an error. The square brackets are empty– aka “no error”. Put a spurious comma in the SQL and you will see what I mean. But your SQL is wildly complicated for you are doing. That is entirely equivalent to SELECT * FROM $table ORDER BY id DESC LIMIT 1 Though, I notice you … Read more

Depreciated Call -> Function wpdb::escape()

prepare works a bit differently than escape in that it works on whole strings and manages quoting as well. $pat = “UPDATE {$wpdb->posts} SET %s = %s WHERE ID = %d”; $qry = $wpdb->prepare( $pat, $key, $visibility, $post_id ); $wpdb->query($qry); You do not need to swap in the table name at all, and with prepare … Read more

wpdb get_row database query inquiry

For Placehold to work, you should use $wpdb->query like: $wpdb->query( $wpdb->prepare( ” SELECT * FROM mailer WHERE id = %d “, $_GET[‘caId’] ) ); However in my opinion, the best option is to simply validate the get-parameter and than use it in $wpdb->get_results , like: $catId = $_GET[‘caId’]; if(is_numeric($catId)){ $_crds = $wpdb->get_results(” SELECT * FROM … Read more

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