PHP syntax error when using wpdb update?

I’m not too good with PHP, so I’m having trouble with some code that is supposed to update the wp_posts table. The problem is that when I try to save it, WP deactivates the plugin saying there’s a syntax error in the following bit of code:

global $wpdb;
$dbresult = $wpdb->update($wpdb->post, ['post_title' => 'Test Title', 'post_content' => 'Test Content', 'group_access' => $group_access, 'tag_list' => $tag_list], ['ID' => 12095])) :
if (false === $dbresult) {
    echo 'An error occurred wile updating...');$errors = $post_id->get_error_messages();
}

I believe it would work if I could figure out what the syntax error was.

1 Answer
1

you’ve got a simple typo, it should read

$dbresult = $wpdb->update($wpdb->posts, ...) ;

that is, $wpdb->posts with a ‘s’, instead of `$wpdb->post’.

Leave a Comment