MySQL database migration to WordPress

From technical perspective wpdb->prepare() essentially trickles down to escaping variables with either (depending on configuration) mysql_real_escape_string() or addslashes(). It’s not inherently more or less secure than any other properly implemented escaping routine. It is closer to specifics of WP and configuration it is aware off.

Inserting into data into external DB using WPDB

You are using $wpdb incorrectly Take a look at these lines: $row = $newdb->get_results(“SELECT * FROM chi_clients WHERE accountNum=’$acctNum'”,ARRAY_A); $name= $row[‘lastName’] . “, ” . $row[‘firstName’]; $wpdb->get_results is going to return an array of “rows”. It is going to multidimensional. You are treating it like it has returned a one-dimensional array. That is, this (completely … Read more

Creating Tables in WordPress Database

It may be a wrong approach, but without creating a plugin, one of my seniors, once did a WordPress Shopping Cart project by creating extra tables for her custom purposes. What she did is to follow the other existing tables in WordPress database. Suppose what wp_posts table has by default is an ID. She opened … Read more

wpdb Cannot Access Associative Array Data in a Count Query

You can simplify that by using $wpdb->get_var. $total = $wpdb->get_var( “SELECT COUNT( * ) AS total FROM tableA” ); echo “Total Records:” . $total; However, the code you’ve got should work– either version of it. I tested both. The only thing I notice is that the first version of the code should give you Array … Read more