• I’m getting this error:

    [08-Apr-2013 13:48:12 UTC] WordPress database error Table 'mytable.wp_users' doesn't exist for query SELECT COUNT(*) FROM wp_users INNER JOIN wp_usermeta ON (wp_users.ID = wp_usermeta.user_id) WHERE 1 = 1 AND ( wp_usermeta.meta_key = 'wp_1_capabilities' ) made by do_action_ref_array, call_user_func_array, Yoast_Tracking->tracking

    The problem is that you forgot to use $wpdb->prefix to get the real database prefix, instead of just assuming that that it was wp_.

    The problem code is in /inc/class-tracking.php on line 113

    http://wordpress.org/extend/plugins/google-analytics-for-wordpress/

Viewing 8 replies - 1 through 8 (of 8 total)
  • amadex

    (@amadex)

    This is problematic… Any fix for the next release?…

    B.

    (@bandonrandon)

    This can be vefified by looking at Trunk:

    'users' => $wpdb->get_var( "SELECT COUNT(*) FROM wp_users INNER JOIN wp_usermeta ON (wp_users.ID = wp_usermeta.user_id) WHERE 1 = 1 AND ( wp_usermeta.meta_key = 'wp_{$blog_id}_capabilities' ) " )

    you should be able to change this to:
    'users' => $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->prefix_users INNER JOIN $wpdb->prefix_usermeta ON ($wpdb->prefix_users.ID = $wpdb->prefix_usermeta.user_id) WHERE 1 = 1 AND ( $wpdb->prefix_usermeta.meta_key = ' $wpdb->prefix_{$blog_id}_capabilities' ) " ),

    This is untested so you may need to escape the $wpdb->prefix not sure.

    Thread Starter J.D. Grimes

    (@jd55)

    Actually, would look like this (untested):

    'users' => $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users INNER JOIN $wpdb->usermeta ON ($wpdb->users.ID = $wpdb->usermeta.user_id) WHERE 1 = 1 AND ( $wpdb->usermeta.meta_key = ' {$wpdb->prefix}{$blog_id}_capabilities' ) " ),

    No need to escape $wpdb when using double quotes. 🙂

    See the docs on $wpdb:

    http://codex.wordpress.org/Class_Reference/wpdb#Class_Variables
    http://codex.wordpress.org/Class_Reference/wpdb#Tables

    Same issue here.
    Any idea how to fix it?
    Where do i change that code?

    Thanks

    @darkpollo – The issue is in /inc/class-tracking.php on line 113. If you change the code yourself, take care, and save a copy of the original file in case you accidentally mess something up.

    Thanks!
    Well, is there any bigproblem if i just ignore the error?

    I just found it, so it has been there months already. 😛

    Yeah, I just ignored it for a long time. I don’t think it really affects the plugin very much.

    I will wait for the official fix then.

    Thank you!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WordPress database error when using prefix other than "wp_"’ is closed to new replies.