Basic wpdb update question

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));

How to get specific attribute from DB

If the data you placed at the beginning of your question is the result of your database query (I’m unsure by how your question is worded), you will want to take that query result and use the PHP function unserialize() to convert that data to an array, then you can access your data from that … Read more

Get posts from category with custom query

It looks like this is the new part of this query causing the problem, is that right? (SELECT term_taxonomy_id FROM wp_BOMEGAterm_relationships WHERE object_id = p.ID) AS categories If so the error message is clear: a sub-select in this query should only return one row. If it returns more than one row it doesn’t know how … Read more

Clear Terms from Taxonomy for Specific Post IDs?

So if you’re sure you want to delete the actual term as well as the relationship that assigns the term to the post, this will do it (tested and works for me): delete term from wpterm_taxonomy term, wpterm_relationships rel where term.term_taxonomy_id = rel.term_taxonomy_id and rel.object_id IN (1) ; And obviously replace the ‘1’ there with … Read more

Save data from a checkbox to a wpdb array

This isn’t a WordPress question this is a PHP question. Your foreach loops through all the $checkboxes putting one in the $check variable each time, so your insert() call only inserts the last value for $check, because it’s not inside that foreach loop. You probably want: global $wpdb; foreach( $checkboxes as $check ) { $wpdb->insert(‘data’,array(‘fruit’ … Read more

CREATE TABLE with dbDelta does not create table

Found a couple of things and am including what I believe will work to correct your issue. (As an aside, you should try and simplify your initial attempts so you can isolate what works and what doesn’t. This is really complex for an initial attempt.) One thing, you’ll struggle to have a field named timestamp, … Read more

Problem migrating to localhost

As in this question and answer, and because of your huge .htaccess file it’s like you have a .htaccess directive that’s causing your apache to not process that file or understand its type. As mentioned by @Rup, using the default WordPress .htaccess, and checking other directories for rogue .htaccess files will likely resolve this issue. … Read more

get_post() is not returning correct value

That’s not how you update posts. Because you used raw SQL to do it, none of the filters or actions fired, and none of WP_Cache was updated, so it’ll return an old version of the post it fetched earlier when you call get_post. Instead, if you want to update a post, use wp_insert_post and pass … Read more

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