0

I am trying to update my sql data through $wpdb, but can't... If anyone can help what's the real issue?

$updated_version = $wpdb->update('wp_visitors', array('views' => $updated), array( '%d' ));

1 Answer 1

1

You're missing your where statement. You need to tell wpdb which row it should be updating, otherwise you're looking to insert rather than update.

From the $wpdb::update Codex:

wpdb->update( string $table, array $data, array $where, array|string $format = null, array|string $where_format = null );
6
  • What should I need to the where statement? I've got only 1 column so as the row. May 1, 2019 at 21:45
  • wp_visitors only has the column views? If that's the case, you probably want to use something other than a custom table. Take a look at options, cache, or transients, depending on your needs. May 1, 2019 at 22:00
  • Sorry I can't understand, and please let me know if there is any possible solution of it? May 1, 2019 at 22:59
  • Your use of a custom table doesn't make sense. May 1, 2019 at 23:56
  • All i want is to get a value to update the Visitor Counter. May 3, 2019 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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