Using WPDB->Insert()

Short answer, no. WPDB is a class that’s been around for a while (back when WP used to support PHP 4), and lacks a lot of features PHP5 drivers offer, including parameter binding. As you mentioned, wpdb::insert is the closest you can get to your original code: $wpdb->insert( ‘importtest’, array( ‘id’ => $ID, ‘area’ => … Read more

$wpdb->query can’t insert data

The following code will properly store data in wp_fafa: $wpdb->insert( $wpdb->prefix . ‘fafa’, array( ‘title’ => trim($row->item(0)->nodeValue), ‘liveprice’ => trim($row->item(2)->nodeValue), ‘changing’ => trim($row->item(4)->nodeValue), ‘lowest’ => trim($row->item(6)->nodeValue), ‘topest’ => trim($row->item(8)->nodeValue), ‘time’ => trim($row->item(10)->nodeValue) ), array( ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’ ) );

how to read database fields

Those are php serialized constructs. The one you have there is an array. If you are looking to read them as a human, it breaks down like this: Array: a:size:{key definition;value definition;(repeated per element)} String: s:size:value There are other possibilities that you can read more about here. Generally, you should never modify these directly since … Read more

Post Views / Hit Counter Problem?

Use the following functionto set views manually function setPostViewsManually($postID, $viewCount) { $count_key = ‘post_views_count’; $count = get_post_meta($postID, $count_key, true); update_post_meta($postID, $count_key, $viewCount); } You can run this code by <?php setPostViewsManually(get_the_ID(), 1234); ?> The above code will set the view to ‘1234’ for the current post. Run this function carefully else your new views will … Read more

Problem in using wpdb

This error: Fatal error: Call to a member function insert() on a non-object Means that $wpdb isn’t instantiated so you are running your code too early or out of WordPress context– for example, in an exterior PHP file accessed directly, which is what I suspect (Poorly conceived AJAX request perhaps?). As mentioned, the code has … Read more

multiple wordpress installation with shared usertable on an different database

After writing those two lines in wp-config.php, your users data will be shared between both installations, but both installations will also need to have the same cookie parameters, so in wp-config.php file of your second installation, modify the COOKIE_DOMAIN like this: define(‘COOKIE_DOMAIN’, ‘.{yoursite.com}’); //replace with URL of first site define(‘COOKIEPATH’, “https://wordpress.stackexchange.com/”);