HTML Entities in Post Title

It seems like the crux of the question is this: This causes the first ‘if’ condition to return TRUE and it inserts a duplicate post. Check for the post_name instead. That value is normalized to lowercase and dashes by sanitize_title_with_dashes so you won’t have this issue. That value is also the one that WordPress enforces … Read more

wpdb_prepare with multiple or condition

I think your first partial code be this partial code: $wpdb->prepare( “SELECT * … from … WHERE ( post_title LIKE ‘%%%s%%’ or post_content LIKE ‘%%%s%%’ )…, $string, $string ); You have to have to pass the same number of arguments into the query as you specify (with %s) in it.

Cannot update custom database table row

Before trying to write to the database, always validate the values you’re putting in: $fValid = true; if ( !isset( $payment->status ) ) { echo ‘Error: Payment status is not set’; $fValid = false; } if ( !isset( $order_id ) ) { echo ‘Error: Order ID is not set’; $fValid = false; } if ( … Read more

How do I properly update the WordPress database password?

This is technically challenging. WordPress must have access to your DB password in plain text. Having access to the wp-config.php contents is already a breach of security in progress. There are alternate approaches to configuration, such as loading credentials via environment variables, but in practice they are used exceedingly rarely because PHP’s configuration file is … Read more

WP Database Table to CSV file

You’ve got a few things wrong. The first is that you are clearly in WordPress context. You should be using the AJAX API for this rather than including wp-load.php. That is virtually never the right way to do it. get_results() defaults to an object, so you are going to get errors when you try to … Read more

Update user_login, user_nicename, and display_name

You don’t need SQL, and shouldn’t use it when Core functions will do the job. Part of the reason why is the complexity of the tables (and the fact they might change). Query your users, loop through pulling metadata, and update Proof of concept: $u = new WP_User_Query( array( ‘role’ => ‘customer’ ) ); foreach … Read more

Error while importing database

When exporting from original database you should choose to create the tables if they dosn’t exist (First error). If you didn’t choose that option (in phpMyAdmin that option exists, not sure in other database tools), the import file can not create the tables for your and you need to create then prior to start importing … Read more