Incorrect Use of wpdb::prepare()

You should try to replace the meta_value = $list->ID part with the placeholder meta_value = %d. Then use the following: $subscriber_count = $wpdb->get_var( $wpdb->prepare( $q, $list->ID ) ); where the input argument $list->ID will be treated as an integer (signed). From the Codex: The query parameter for prepare accepts sprintf()-like placeholders. The %s (string), %d … Read more

Retrieving posts by their date and category

Please try the following code: Following code has to be added in shortcode function global $wpdb; $start .= $attr[‘godina’] . “-09-01”; $end .= $attr[‘godina’] + 1 . “-08-31”; $cat = $attr[‘cat’]; //$cat must be category name. $cat_term_id=get_term_by(‘name’, $cat, ‘category’); $term_id=$cat_term_id->term_id; $query = array( ‘post_type’ => ‘post’, ‘tax_query’ => array(array( ‘taxonomy’ => ‘category’, ‘field’ => ‘term_id’, … Read more

Use AJAX in a WordPress Plugin to Get Data From Custom Database?

You can use like this for send ajax… function my_action_javascript() { ?> <script type=”text/javascript”> jQuery(document).ready(function ($) { var data = { ‘action’: ‘my_action’, ‘whatever’: ‘1’ }; $.post(ajaxurl, data, function (response) { if ($(‘#menu_order’).val() == ” || $(‘#menu_order’).val() == ‘0’) $(‘#menu_order’).val(response); }); }); </script> <?php } add_action(‘admin_footer’, ‘my_action_javascript’); function my_action_callback() { $whatever = intval($_POST[‘whatever’]); //$whatever += … Read more

WPDB secure custom form

When getting user input to be stored on database, a good way to proceed is: Data validation: validate the data according whith the data you expect. For example: HTML string, number, email, URL, any text with no HTML, ect. Never trust on user input or client-side validation. You can make here also some sanitization, but … Read more

Save sql file after doing insert wpdb

Trivial! $wpdb->last_query will hold it. 🙂 For more extensive log you might want to define SAVEQUERIES constant to true in configuration. Full log then will be available in $wpdb->queries. It’s off by default for performance reasons.

Displaying data from another database

And there is your issue — WordPress does need to understand URL. Otherwise it is indeed 404 because it doesn’t correspond to anything WP “knows”. You need to create that understanding, for example by using Rewrite API. Also since your data is external and isn’t really a part of WP context, you will probably need … Read more

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