$wpdb->insert Giving duplicates

There is nothing that prevent duplicates here. When you create the table ‘church’ is a good idea set a UNIQUE sql index for field email, in this way you can rely on email address to preventing duplicate entries. As a generic PHP good practice, you should check the existence of a a variable before using … Read more

WordPress is trimming leading 0s

%d means integer, integers don’t have leading zeros. Zip codes aren’t numbers in the sense that they quantify something, they’re strings that happen to be made up of numbers, so treat them as strings.

How to display a specific category using a custom Query?

If you insist on continuing on this path using SQL queries, you should first understand how taxonomy terms connect to posts: $wpdb->posts.ID <–> $wpdb->term_relationships.object_id $wpdb->term_relationships.term_taxonomy_id <–> $wpdb->term_taxonomy.term_taxonomy_id $wpdb->term_taxonomy.term_id <–> $wpdb->terms.term_id With this in mind, and assuming you’re providing the $taxonomy (string) and $term_slug (string) parameters for the category you’re filtering by, I envision your code … Read more

Trying to Connect to different database

I’m looking at wp-db.php and see: 1384 if ( $this->dbh->connect_errno ) { 1385 $this->dbh = null; This is in the class function db_connect(), which is called by the wpdb constructor. In the latest error you describe: Warning: mysql_error() expects parameter 1 to be resource, boolean given we can see that mysql_error() is not receiving the … Read more

Custom query: Get all posts that are from a certain category?

it’s quite easy: $months = $wpdb->get_col(“SELECT DATE_FORMAT(post_date_gmt, ‘%m’) 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 = 11 AND DATE_FORMAT(post_date_gmt, ‘%Y’) = $y GROUP BY DATE_FORMAT(post_date_gmt, ‘%Y-%m’) ORDER BY post_date_gmt DESC”); term_taxonomy_id is the category. And I join on the object ID

I can’t figure out what’s wrong with this statement. $wpdb->query update

Without an error message, it is difficult to tell the exact problem. It is important to debug within WordPress and check your webserver error logs. One problem is your call of prepare(). The method takes 2 or more arguments, you only passed 1. Instead try the following $update_status = $wpdb->query($wpdb->prepare( “UPDATE {$wpdb->prefix}wcpv_commissions SET commission_status = … Read more

How to get last user with wpdb?

If you’re trying to get the last user created with the username format usuario*, I’d recommend using get_users() instead of writing a SQL query. $args = array( “search” => “usuario*”, // Search string “search_columns” => array( “user_login” ), // Field(s) to search “order” => “DESC”, // Search order “orderby” => “user_registered”, // Order by this … Read more

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