Trouble running $wpdb->query() with last_insert_id
You can get the last inserted ID from $wpdb with the insert_id property: $wpdb->insert( … ); $couponId = $wpdb->insert_id
You can get the last inserted ID from $wpdb with the insert_id property: $wpdb->insert( … ); $couponId = $wpdb->insert_id
You’re missing your where statement. You need to tell wpdb which row it should be updating, otherwise you’re looking to insert rather than update. From the $wpdb::update Codex: wpdb->update( string $table, array $data, array $where, array|string $format = null, array|string $where_format = null );
Yes, usually you create a new database, user and password as well as use another copy of WordPress to create a new site. You can create a new directory in the same place where the “wordpress” directory is located and use that one for the new site. Note that it is possible to use the … Read more
Got it…took all day, but now finally I can finally sleep. This solution is for a set of databases that reside on the same server, even if they are in different accounts. Thus you do not need to set the remote server access in the CPanel. The key is to find the user name and … Read more
You should have not searched the field and replaced all the references to wp_ with anything. For example : the value of the entry with meta_key wp_page_for_privacy_policy will be change to wp_addtionnal_prefix page_for_privacy_policy. Hence there could be a lot of misfitted values in your table. A better way would have been to : export the … Read more
You can set up a new connection from function: $wpdb_b = new wpdb( “user”, “password”, “brian_db”, “localhost” ); $wpdb_b->get_results( “SELECT * FROM brian_table” ); Happy Coding
Hopefully i understood correctly what you want to achieve here. If you want to exclude all posts that contain get_current_user_id() in the project_users ACF repeater, but at the same time contains has get_current_user_id() in favourite_users, the correct meta query looks like this: ‘meta_query’ => array( ‘relation’ => ‘AND’, array( array( ‘key’ => ‘project_users’, ‘value’ => … Read more
Why am I getting this error? Because the table wp_term_taxonomy does not have the column object_id. And the correct table that you should update is the wp_term_relationships table which does have the column object_id. See the WordPress database diagram and also the WordPress database description for more details. So your SQL query should be: UPDATE … Read more
Slugs are saved in the very same table but in the post_name column. So your query would look like this: UPDATE wp_posts SET post_name = REPLACE(post_name, ‘m’ , ‘p’) WHERE post_type=”post” AND post_status=”publish”; By the way, I’d suggest you to use $wpdb->posts instead of just wp_posts ( then it would be compatible with different prefixes, … Read more
I think the line should be: $selected_candidate = $_POST[‘candidat’]; => $selected_candidate = $_POST[‘selectCandidate’] Btw. You are using “prepare” in the wrong way. You are not protecting yourself from sql injections, use it like this: $wpdb->query( $wpdb->prepare(“UPDATE pp_candidates SET candidate_approved = 1 WHERE candidate_ID = %d”, $selected_candidate));