how to use $wpdb->prepare to update a custom table

When you look at the Codex article on $wpdb, then you will see that your current usage is correct. The last argument array( ‘%s’, ‘%d’, ‘%s’ ) already indicates that there is something like sprintf/printf going on in the background. The $wpdb->prepare() method isn’t needed for every other method. The ones that need it: $wpdb->query() … Read more

$wpdb->prepare with ON DUPLICATE KEY UPDATE

It’s my fault. Got the solution after @Otto’s comment: Do you actually have a duplicate key here? What is the structure of user_req and what are the keys and indexes? Here’s how my SQL query should be: INSERT INTO {$wpdb->prefix}user_req ( user_id, post_id ) VALUES ( %d, %d ) WHERE NOT EXISTS ( SELECT * … Read more

Plugin will sort users by usermeta

If you want best practices of the options you listed use the user meta table. Adding a column to the users table would be the worst thing you could do – messing with table structure of default WP tables is a no-no. The other two options would fall somewhere in between – with adding your … Read more

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