How to count data records in wordpress which have same meta_value in wp_postmeta table?

<?php global $wpdb; $table_name = $wpdb->prefix . “postmeta”; $login_name = sanitize_user( $_POST[‘parent_id’] ); $prepare = $wpdb->prepare( “SELECT COUNT(*) FROM $table_name WHERE meta_value=”Purva” AND meta_key = ‘parent_id’ “, $login_name ); $myrows = $wpdb->get_results( $prepare ); echo ‘<pre>’ . print_r( $myrows, true ) . ‘</pre>’; ?> I tried this and get values but still something missing…

$wpdb is get_results escaped

The answer is: of course they are not – otherwise you couldn’t use them to save them in DB. But… the answer to your question isn’t so easy. Sanitizing is a process of preparing data for storing in DB. So for example if you insert some illegal characters in post_name, then it will be removed, … Read more

why creating tables using $wpdb is not being executed while installing plugins?

Try using a different method. WordPress fires a hook during plugin activation activate_yourplugin/filename.php. You can use this to create tables. function creating_order_tables() { if(!get_option(‘tables_created’, false)) { global $wpdb; $ptbd_table_name = $wpdb->prefix . ‘printtextbd_order’; if ($wpdb->get_var(“SHOW TABLES LIKE ‘”. $ptbd_table_name .”‘” ) != $ptbd_table_name ) { $sql=”CREATE TABLE exone( customer_id INT(20) AUTO_INCREMENT, customer_name VARCHAR(255), order_type VARCHAR(255), … Read more

How Can I Use $wpdb in PayPal IPN file?

Use the ajax api: http://codex.wordpress.org/AJAX_in_Plugins If you let all your ajax calls go through this you will have access to all WP functions. Also take a look at these: http://www.james-vandyne.com/process-paypal-ipn-requests-through-wordpress/ http://wordpress.org/extend/plugins/paypal-framework/ Don’t know if what you want is in there, but worth a look.

What does wp_update_post() do that the $wpdb class does not?

wp_update_post() calls some hooks that $wpdb doesn’t on it’s own. You’ll have to do it on your own to make it compatible with other plugins. wp_update_post() calls some functions related to database entry sanitation, thumbnails, attachments, time (format, zone etc.), comment, taxonomy, meta, cache etc. So if you use $wpdb, make sure you handle all … Read more

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