Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

$wpdb->insert(
    'wp_pagesvisites',
    array(
        'Adresse_IP' => $ip,
        'Post_ID' => $id,
        'Timestamp' => $time
    )
);

Thanks for helping!

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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

global $wpdb;
$wpdb->insert();

… or access it per $GLOBALS

$GLOBALS['wpdb']->insert();

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

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

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.