0

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!

3

$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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy