WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have very few knowledge on oo php and databases, and I am simply trying to insert data in my wp_pagesvisites table but I am having some trouble with this error message.

This is my script:

        'Adresse_IP' => $ip,
        'Post_ID' => $id,
        'Timestamp' => $time

Thanks for helping!

share|improve this question
up vote 3 down vote accepted

$wpdb is a global variable. You have to take it into your function’s scope first …

global $wpdb;

… or access it per $GLOBALS


And I would use always lowercase keys; this is just a useful convention.

share|improve this answer
thanks toscho for all of your answers!! – user25893 Jan 18 '13 at 22:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.