WordPress db prepare

From the Codex, 2nd parameter for the prepare() method: (int|string|array) The value to substitute into the placeholder. Many values may be passed by simply passing more arguments in a sprintf()-like fashion. Alternatively the second argument can be an array containing the values as in PHP’s vsprintf() function. Care must be taken not to allow direct … Read more

I’m not able to get access to $wpdb [duplicate]

If you’re not using WP’s built in Ajax handlers, which includes things for you, you will need to include the WP core yourself. Try adding define(‘WP_USE_THEMES’, false); global $wpdb; require(BASE_PATH . ‘wp-load.php’); to the top of your file. I should point out that the path to wp-load.php may not be the same and hard coding … Read more

after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()

prepare() takes at least 2 parameters. Most of your calls to prepare() are not needed. For example: $blogids = $wpdb->get_col($wpdb->prepare(“SELECT blog_id FROM $wpdb->blogs”)); In this code, if the call to $wpdb->prepare() were valid, it wouldn’t do anything. The function doesn’t do anything to the first parameter. It manipulates the values in the other parameters passed … Read more

PHP Fatal Error – $wpdb a non-object?

“the errors (…) don’t show a stack trace” – they would if you were using xdebug. It means $wpdb is not loaded yet, not loaded properly, or gone: If you added code that calls it to your wp-config file or something to that order, remove it. If you’ve a db.php file in wp-content, it’s probably … Read more

Insert custom postmeta when custom post type published

Newer New solution: function wpse153622_transition_solution( $new_status, $old_status, $post ) { if ( $new_status != $old_status && ‘publish’ === $new_status && ‘my-solution’ === $post->post_type ) { update_post_meta( $post_id, ‘my_json’, ‘json’ ); } } add_action( ‘transition_post_status’, ‘wpse153622_transition_solution’, 10, 3 ); This should trigger only when 1. the new post status isn’t the same as the old one … Read more

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