-1

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.

user1934286
  • 1,732
  • 3
  • 23
  • 42

1 Answers1

1

There were multiple errors. It should be fixed now.

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]); // <- One ) to much, : but needed ;
if (false === $dbresult) {
    echo ('An error occurred while updating...'); // <- Missing (
    $errors = $post_id->get_error_messages();
}
Larce
  • 841
  • 8
  • 17